Пример #1
0
        public override global::System.Data.DataSet Clone()
        {
            DataSetSync cln = ((DataSetSync)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Пример #2
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DataSetSync ds = new DataSetSync();

            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);
        }
Пример #3
0
        public DataSetSync GetFilesChanges(DateTime timeStamp, long[] pdaFiles, long fromId, long toId)
        {
            DataSetSync ds = new DataSetSync();

            FillChanges(timeStamp, pdaFiles, ds.Files, "[id], [Name], [Size], [Date], [Parent], [Disk], [Attributes]", "[Files]", fromId, toId);

            return ds;
        }
Пример #4
0
        public DataSetSync GetFiles(long diskId)
        {
            DataSetSync ds = new DataSetSync();

            DBUtils.FillDataTable(ds.Files, this.DBConString, "SELECT [id], [Name], [Size], [Date], [Parent], [Attributes] FROM [Files] WHERE [Disk] = " + diskId, new object[] {});

            return ds;
        }
Пример #5
0
        public DataSetSync GetDisksChanges(DateTime timeStamp, long[] pdaDisks)
        {
            DataSetSync ds = new DataSetSync();

            FillChanges(timeStamp, pdaDisks, ds.Disks, "[id], [Name], [Description], [CDBox] AS [Box]", "[Disks]", 0, -1);

            return ds;
        }
Пример #6
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;
            }
        }
Пример #7
0
        public DataSetSync GetCategories()
        {
            DataSetSync ds = new DataSetSync();

            try
            {
                DBUtils.FillDataTable(ds.Categories, this.DBConString, "SELECT [id], [Name], [Parent], [LastUpdate] FROM [Categories]", new object[] { });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return ds;
        }
Пример #8
0
        public DataSetSync GetBoxesChanges(DateTime timeStamp, long[] pdaBoxes)
        {
            DataSetSync ds = new DataSetSync();

            FillChanges(timeStamp, pdaBoxes, ds.Boxes, "[id], [Name], [Description], [Category]", "[CDBoxes]", 0, -1);

            return ds;
        }