Inheritance: BaseEntity, IBusinessVersionedEntity
コード例 #1
0
ファイル: ExcelWriter.cs プロジェクト: BEXIS2/Core
        /// <summary>
        /// Convert a Datatuple to a Row
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="dataTuple">Datatuple to convert</param>
        /// <param name="rowIndex">Position of the Row</param>
        /// <returns></returns>
        protected Row DatatupleToRow(AbstractTuple dataTuple, int rowIndex)
        {
            Row row = new Row();
            row.RowIndex = Convert.ToUInt32(rowIndex);

            int columnIndex = 0;
            columnIndex += offset;

            // need to add this empty cell to add cells to the right place
            row.AppendChild(GetEmptyCell(rowIndex, 0));

            foreach (VariableIdentifier variableIdentifier in VariableIdentifiers)
            {
                VariableValue variableValue = dataTuple.VariableValues.Where(p => p.VariableId.Equals(variableIdentifier.id)).First();
                Cell cell = VariableValueToCell(variableValue, rowIndex, columnIndex);
                row.AppendChild(cell);
            }

            return row;
        }
コード例 #2
0
ファイル: AsciiWriter.cs プロジェクト: BEXIS2/Core
        /// <summary>
        /// Convert Datatuple to  String line
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="dataTuple"></param>
        /// <returns></returns>
        private string datatupleToRow(AbstractTuple dataTuple)
        {
            StringBuilder builder = new StringBuilder();
            StructuredDataStructure sds = GetDataStructure();

            bool first = true;
            string value = "";

            foreach (VariableIdentifier vi in this.VariableIdentifiers)
            {
                Variable variable = sds.Variables.Where(p => p.Id == vi.id).SingleOrDefault();

                if (variable != null)
                {
                    Dlm.Entities.DataStructure.DataType dataType = variable.DataAttribute.DataType;

                    VariableValue vv = dataTuple.VariableValues.Where(v => v.Variable.Id.Equals(vi.id)).FirstOrDefault();

                    if (vv !=null && vv.Value != null)
                    {
                        string format = GetStringFormat(dataType);
                        if (!string.IsNullOrEmpty(format))
                        {
                            value = GetFormatedValue(vv.Value, dataType, format);
                        }
                        else value = vv.Value.ToString();
                    }
                }
                // Add separator if this isn't the first value
                if (!first)
                    builder.Append(AsciiHelper.GetSeperator(Delimeter));
                // Implement special handling for values that contain comma or quote
                // Enclose in quotes and double up any double quotes
                if (value.IndexOfAny(new char[] {'"', ','}) != -1)
                    builder.AppendFormat("\"{0}\"", value.Replace("\"", "\"\""));
                else
                    builder.Append(value);
                first = false;
            }

            return builder.ToString();
        }
コード例 #3
0
ファイル: UploadWizardHelper.cs プロジェクト: BEXIS2/Core
        /// <summary>
        ///  convert primary keys to string
        ///  returns null if a emtpy string is inside
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="datatuple"></param>
        /// <param name="primaryKeys"></param>
        /// <returns></returns>
        private static string getPrimaryKeysAsStringFromXml(AbstractTuple datatuple, List<long> primaryKeys)
        {
            string value = "";

                foreach (long t in primaryKeys)
                {
                    // empty means not equals value
                    // so if value is empty add timestamp millisec
                    //datatuple.Materialize();
                    object v = GetValueXmlDocument(datatuple.XmlVariableValues, t);
                    if (v != null)
                        //if (!String.IsNullOrEmpty(v.ToString()))
                        if (!String.IsNullOrEmpty((string)v))
                            value += ";" + v;
                        else
                            return "";
                    else
                        return "";
                }
                return value;
        }
コード例 #4
0
ファイル: SearchUIHelper.cs プロジェクト: BEXIS2/Core
        /// <summary>
        /// This function convert a datatuple into datarow for a datatable to show on the client side
        /// the grid in the client side (in client mode) has unknow problem with value 0 and null
        /// So every empty cell get the max value of the specific Systemtype.
        /// On the client side this values replaced with ""
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        private static DataRow ConvertTupleIntoDataRow(DataTable dt, AbstractTuple t, StructuredDataStructure sts)
        {
            DataRow dr = dt.NewRow();

            foreach(var vv in t.VariableValues)
            {
                if (vv.VariableId > 0)
                {
                    string valueAsString="";
                    if (vv.Value == null)
                    {
                        dr["ID" + vv.VariableId.ToString()] = DBNull.Value;
                    }
                    else
                    {
                        valueAsString = vv.Value.ToString();

                        Variable varr = sts.Variables.Where(p => p.Id == vv.VariableId).SingleOrDefault();
                        switch (varr.DataAttribute.DataType.SystemType)
                        {
                            case "String":
                            {
                                dr["ID" +vv.VariableId.ToString()] = valueAsString;
                                break;
                            }

                            case "Double":
                            {
                                double value;
                                if (double.TryParse(valueAsString, out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToDouble(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = -99999;//double.MaxValue;
                                break;
                            }

                            case "Int16":
                            {
                                Int16 value;
                                if(Int16.TryParse(valueAsString,out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToInt16(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = Int16.MaxValue;
                                break;
                            }

                            case "Int32":
                            {
                                Int32 value;
                                if(Int32.TryParse(valueAsString,out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToInt32(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = Int32.MaxValue;
                                break;
                            }

                            case "Int64":
                            {
                                Int64 value;
                                if(Int64.TryParse(valueAsString,out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToInt64(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = Int64.MaxValue;
                                break;
                            }

                            case "Decimal":
                            {
                                decimal value;
                                if (decimal.TryParse(valueAsString, out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToDecimal(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = -99999;//decimal.MaxValue;
                                break;
                            }

                            case "Float":
                            {
                                decimal value;
                                if (decimal.TryParse(valueAsString, out value))
                                    dr["ID" + vv.VariableId.ToString()] = Convert.ToDecimal(valueAsString);
                                else
                                    dr["ID" + vv.VariableId.ToString()] = -99999;
                                break;
                            }

                            case "DateTime":
                            {
                                    if (!String.IsNullOrEmpty(valueAsString))
                                        dr["ID"+vv.VariableId.ToString()] = Convert.ToDateTime(valueAsString, CultureInfo.InvariantCulture);
                                    else
                                        dr["ID" + vv.VariableId.ToString()] = DateTime.MaxValue;

                                break;
                            }

                            default:
                            {
                                if (!String.IsNullOrEmpty(vv.Value.ToString()))
                                    dr["ID"+vv.VariableId.ToString()] = valueAsString;
                                else
                                    dr["ID" + vv.VariableId.ToString()] = DBNull.Value;

                                break;
                            }
                        }
                    }

                    /*if (vv.ParameterValues.Count > 0)
                    {
                        foreach (var pu in vv.ParameterValues)
                        {
                            dr[pu.Parameter.Label.Replace(" ", "")] = pu.Value;
                        }
                    }*/
                }
            }

            return dr;
        }
コード例 #5
0
ファイル: UploadWizardHelper.cs プロジェクト: BEXIS2/Core
        /// <summary>
        /// 
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="newDatatuple"></param>
        /// <param name="sourceDatatuple"></param>
        /// <returns></returns>
        //temporary solution: norman :Equal2
        private static bool Equal(AbstractTuple newDatatuple, AbstractTuple sourceDatatuple)
        {
            foreach(VariableValue newVariableValue in newDatatuple.VariableValues )
            {
                long varID = newVariableValue.VariableId;

                object ValueNew = newVariableValue.Value;

                object ValueSource = GetValueXmlDocument(sourceDatatuple.XmlVariableValues, varID);

                if (!ValueNew.Equals(ValueSource))
                    return false;
            }

            return true;
        }