public override global::System.Data.DataSet Clone()
        {
            DataSetTemp cln = ((DataSetTemp)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DataSetTemp ds = new DataSetTemp();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Esempio n. 3
0
        public DataSetSync GetCategoriesChanges(DateTime timeStamp, long[] pdaCategories)
        {
            /// Flag Values:
            /// 0 - New
            /// 1 - Updated
            /// 2 - Deleted

            try
            {
                string inPart = "";

                if ((null != pdaCategories) && (pdaCategories.Length > 0))
                {
                    inPart += "(" + pdaCategories[0];

                    for (int i = 1; i < pdaCategories.Length; i++)
                    {
                        inPart += ", " + pdaCategories[i];
                    }

                    inPart += ")";
                }

                DataSetSync ds = new DataSetSync();

                string sql = null;

                if (false == string.Empty.Equals(inPart))
                {
                    sql = "SELECT [id], [Name], [Description], [Parent], 1 AS [Flag] FROM [Categories] WHERE DATEDIFF(\"s\",  [LastUpdate], '" + timeStamp.ToString("dd/MM/yyyy hh:mm:ss") + "') < 0";

                    sql += " AND [id] IN " + inPart;

                    DBUtils.FillDataTable(ds.Categories, this.DBConString, sql, new object[] {});
                }

                sql = "SELECT [id], [Name], [Description], [Parent], 0 AS [Flag] FROM [Categories]";

                if (false == string.Empty.Equals(inPart))
                {
                    sql += " WHERE [id] NOT IN " + inPart;
                }

                DBUtils.FillDataTable(ds.Categories, this.DBConString, sql, new object[] {});

                sql = "SELECT [id] FROM [Categories]";

                if (false == string.Empty.Equals(inPart))
                {
                    sql += " WHERE [id] IN " + inPart;
                }

                if ((null != pdaCategories) && (pdaCategories.Length > 0))
                {
                    DataSetTemp dsTemp = new DataSetTemp();

                    DBUtils.FillDataTable(dsTemp.Temp, this.DBConString, sql, new object[] {});

                    foreach (int id in pdaCategories)
                    {
                        if (null == dsTemp.Temp.Rows.Find(id))
                        {
                            DataSetSync.CategoriesRow drDeleted = ds.Categories.NewCategoriesRow();
                            drDeleted.Flag = 2;
                            drDeleted.id = id;
                            ds.Categories.AddCategoriesRow(drDeleted);
                        }
                    }
                }

                return ds;
            }
            catch (OleDbException ex)
            {
                MessageBox.Show(ex.Message);

                return null;
            }
        }
Esempio n. 4
0
        public void FillChanges(DateTime timeStamp, long[] existingIds, DataTable dtToFill, String fields, String table, long fromId, long toId)
        {
            /// Flag Values:
            /// 0 - New
            /// 1 - Updated
            /// 2 - Deleted

            try
            {
                string inPart = "";

                if ((null != existingIds) && (existingIds.Length > 0))
                {
                    inPart += "(" + existingIds[0];

                    for (int i = 1; i < existingIds.Length; i++)
                    {
                        inPart += ", " + existingIds[i];
                    }

                    inPart += ")";
                }

                string sql = null;

                string idBetween = "[id] >= " + fromId;

                if (toId != -1)
                {
                    idBetween += " AND [id] <= " + toId;
                }

                if (false == string.Empty.Equals(inPart))
                {
                    sql = "SELECT " + fields + ", 1 AS [Flag] FROM " + table + " WHERE " + idBetween + " AND DATEDIFF(\"s\",  [LastUpdate], '" + timeStamp.ToString("dd/MM/yyyy hh:mm:ss") + "') < 0";

                    sql += " AND [id] IN " + inPart;

                    sql += " ORDER BY [id]";

                    DBUtils.FillDataTable(dtToFill, this.DBConString, sql, new object[] {});
                }

                sql = "SELECT " + fields + ", 0 AS [Flag] FROM " + table + " WHERE " + idBetween;

                if (false == string.Empty.Equals(inPart))
                {
                    sql += " AND [id] NOT IN " + inPart;
                }

                sql += " ORDER BY [id]";

                DBUtils.FillDataTable(dtToFill, this.DBConString, sql, new object[] {});

                sql = "SELECT [id] FROM " + table + " WHERE " + idBetween;

                if (false == string.Empty.Equals(inPart))
                {
                    sql += " AND [id] IN " + inPart;
                }

                if ((null != existingIds) && (existingIds.Length > 0))
                {
                    DataSetTemp dsTemp = new DataSetTemp();

                    DBUtils.FillDataTable(dsTemp.Temp, this.DBConString, sql, new object[] {});

                    foreach (int id in existingIds)
                    {
                        if (null == dsTemp.Temp.Rows.Find(id))
                        {
                            DataRow drDeleted = dtToFill.NewRow();
                            drDeleted["Flag"] = 2;
                            drDeleted["id"] = id;
                            dtToFill.Rows.Add(drDeleted);
                        }
                    }
                }
            }
            catch (OleDbException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }