Пример #1
0
 public MessageEmbed AddField(string name, string value, bool inline = false)
 {
     Fields.Append(new EmbedField
     {
         Name   = name,
         Value  = value,
         Inline = inline
     });
     return(this);
 }
Пример #2
0
        public int AddCustomField(string Query)
        {
            if (Fields.Length != 0)
            {
                Fields.Append(",");
                FieldsWithoutAlias.Append(",");
            }

            if (EntityCount >= 1)
            {
                Fields.Append(string.Concat(" ", Query, " as [", ++FieldCount, "]")).AppendLine();
            }
            else
            {
                return(0);
            }

            FieldsWithoutAlias.Append(string.Concat(" ", Query)).AppendLine();

            return(FieldCount - 1); //IMPORTANTE Retorna -1 porque o GetData busca os campos por indice e não por nome.
        }
Пример #3
0
        public int AddField(string pEntity, string pAttribute)
        {
            if (Fields.Length != 0)
            {
                Fields.Append(",");
                FieldsWithoutAlias.Append(",");
            }

            if (EntityCount >= 1)
            {
                Fields.Append(string.Concat(" [", pEntity, "].[", pAttribute, "] as [", ++FieldCount, "]")).AppendLine();
            }
            else
            {
                return(0);
            }

            FieldsWithoutAlias.Append(string.Concat(" [", pEntity, "].[", pAttribute, "]")).AppendLine();

            return(FieldCount - 1); //IMPORTANTE Retorna -1 porque o GetData busca os campos por indice e não por nome.
        }
Пример #4
0
        internal static Recordset ConvertListToRecordSet <T>(IEnumerable <T> data)
        {
            Recordset rs = new Recordset();

            rs.CursorLocation = CursorLocationEnum.adUseClient;

            Fields rsFields = rs.Fields;

            PropertyInfo[]   props            = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
            HashSet <string> doNotExportProps = new HashSet <string>();

            foreach (PropertyInfo prop in props)
            {
                var att = prop.GetCustomAttribute <DoNotExportToWorksheetAttribute>();
                if (att == null)
                {
                    if (prop.PropertyType == typeof(Guid))
                    {
                        rsFields.Append(prop.Name, DataTypeEnum.adVarChar, -1, FieldAttributeEnum.adFldMayBeNull);
                    }
                    else
                    {
                        rsFields.Append(prop.Name, TranslateToAdodbType(prop.PropertyType), -1, FieldAttributeEnum.adFldMayBeNull);
                    }
                }
                else
                {
                    doNotExportProps.Add(prop.Name);
                }
            }

            rs.Open(Missing.Value, Missing.Value, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0);
            foreach (T item in data)
            {
                int i = 0;
                rs.AddNew(Missing.Value, Missing.Value);
                for (int j = 0; j < props.Length; j++)
                {
                    PropertyInfo prop = props[j];
                    if (!doNotExportProps.Contains(prop.Name))
                    {
                        if (prop.PropertyType == typeof(Guid))
                        {
                            rsFields[i].Value = prop.GetValue(item);
                        }
                        else
                        {
                            var val = prop.GetValue(item);
                            if (val != null)
                            {
                                rsFields[i].Value = val;
                            }
                        }
                        i++;
                    }
                }
            }
            if (rs.RecordCount > 0)
            {
                rs.MoveFirst();
            }

            return(rs);
        }
Пример #5
0
        public static Recordset GetRecordSet(DataGridView dataGridView)
        {
            //string mthdNamespace = "ReportsLibrary.DGVRecordSet.GetRecordSet";
            if (dataGridView == null)
            {
                //Logging.LogEvent("ArgumentNull", mthdNamespace, new List<Logging.Arguments> { new Logging.Arguments() { ArgumentName = "dataGridView", ArgumentValue = "Null" } });
                return(null);
            }

            try
            {
                Recordset result = new Recordset();
                result.CursorLocation = CursorLocationEnum.adUseClient;
                Fields resultFields = result.Fields;
                DataGridViewColumnCollection iColumns = dataGridView.Columns;



                foreach (DataGridViewColumn iColumn in iColumns)
                {
                    if (iColumn.Visible == true)
                    {
                        DataTypeEnum fieldType = TranslateType(iColumn.ValueType);
                        if (fieldType == DataTypeEnum.adVarChar)
                        {
                            resultFields.Append(iColumn.HeaderText, fieldType, 300);
                        }
                        else
                        {
                            iColumn.HeaderText = iColumn.HeaderText == "" ? "{Empty}" : iColumn.HeaderText;
                            resultFields.Append(iColumn.HeaderText, fieldType);
                        }
                    }
                }

                result.Open();

                foreach (DataGridViewRow iRow in dataGridView.Rows)
                {
                    result.AddNew();
                    foreach (DataGridViewColumn iColumn in dataGridView.Columns)
                    {
                        if (iColumn.Visible == true)
                        {
                            if (iRow.Cells[iColumn.Index].Value == null)
                            {
                                if (iColumn.ValueType == typeof(String))
                                {
                                    iRow.Cells[iColumn.Index].Value = "";
                                }

                                if (iColumn.ValueType == typeof(Boolean))
                                {
                                    iRow.Cells[iColumn.Index].Value = false;
                                }
                            }

                            if (iRow.Cells[iColumn.Index].Value.GetType() == typeof(DBNull))
                            {
                                if (iColumn.ValueType == typeof(String))
                                {
                                    iRow.Cells[iColumn.Index].Value = "";
                                }

                                if (iColumn.ValueType == typeof(Boolean))
                                {
                                    iRow.Cells[iColumn.Index].Value = false;
                                }
                            }


                            resultFields[iColumn.HeaderText].Value = iRow.Cells[iColumn.Index].Value;
                        }
                    }
                }

                if (!result.BOF)
                {
                    result.MoveFirst();
                }
                return(result);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception");
                //Logging.LogException(ex);
                return(null);
            }
        }
Пример #6
0
        /// <summary>
        /// 其他清单判断流程
        /// </summary>
        /// <param name="row"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public IdentityResult ProcessOther(Excel row, RulesAdapter db)
        {
            var professional = row.ZY;
            var ID           = row.QDBH;

            row.QDBH = "其他";
            var identity = ProcessOther(row, db, "其他");
            var items    = new Dictionary <string, DataRow>();
            var name     = FormatNameUseGlobalRule(row.QDMC, row.ZY);

            row.QDBH = ID;

            if (identity.State == IdentityResultStateEnum.Success)
            {
                identity.State = IdentityResultStateEnum.Success;

                foreach (DataRow rule in identity.RulesMatched)
                {
                    var limit = rule.Field <string>("BZ2");
                    var unit  = rule.Field <string>("DEDW");

                    if (!string.IsNullOrEmpty(limit) && !string.IsNullOrEmpty(unit))
                    {
                        if (limit.Contains("1") && unit != row.DW.ToUpper() && unit != row.DW.ToLower())
                        {
                            continue;
                        }
                    }

                    var fields = new Fields("express", rule.Field <string>("DEBS"))
                                 .Append("unit", rule.Field <string>("YZJFS"));

                    var pattern = Pattern.Parse(fields);
                    if (pattern == null)
                    {
                        continue;
                    }

                    var newname = FormatNameUseQuotaRule(name, row.ZY, rule);
                    fields.Append("sample", newname);
                    if (pattern.IsMatch(fields) == false)
                    {
                        row.Log(row.QDMC + " 与 " + fields["express"] + " 不匹配");
                        continue;
                    }

                    var group = rule.Field <string>("FZ");

                    if (items.ContainsKey(group) == false)
                    {
                        items[group] = rule;
                        name         = RemoveScopeUseRule(name, rule.Field <string>("ZYFL4"));
                    }
                }
            }

            if (items.Count == 0)
            {
                identity.State = IdentityResultStateEnum.Unable;
                return(identity);
            }

            identity.RulesMatched.Clear();
            foreach (DataRow item in items.Values)
            {
                var DEBH = item.Field <string>("DEBH");
                identity.RulesMatched.Add(item);

                row.Log("已录入定额,号码为:" + DEBH);
            }

            return(identity);
        }