public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     ProductsDataSet ds = new ProductsDataSet();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "ProductsTblDataTable";
     type.Attributes.Add(attribute2);
     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;
 }
Пример #2
0
        /// <summary>
        /// Печать этикетки. На вход - строка данных и код действия
        /// Код этикетки определяется динамически на основе поля в строке данных и кода действия.
        /// </summary>
        /// <param name="datarow">Строка с данными</param>
        /// <param name="code">Код действия</param>
        public void PrintLabel(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docRow)
        {
            string fileContent = string.Empty;
            int fileLength = 0;
            byte[] bArray = null;
            uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docRow.DocType, (uint)docRow.LabelCode);
            if (labelCollection.ContainsKey(shablonCode))
            {
                bArray = labelCollection[shablonCode];
                fileLength = bArray.Length;
                fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray);
            }
            else
            {
                string labelName = string.Format("LABEL_{0}.DEF", shablonCode);
                if (System.IO.File.Exists(System.IO.Path.Combine(Program.StartupPath, "fam_pr.lbl")))
                {
                    using (System.IO.FileStream fs = System.IO.File.OpenRead(System.IO.Path.Combine(Program.StartupPath, "fam_pr.lbl")))
                    {
                        fileLength = (int)fs.Length;
                        bArray = new byte[fileLength];
                        fs.Read(bArray, 0, fileLength);
                        fs.Close();
                    }
                    labelCollection.Add(shablonCode, bArray);
                }

            }
            if (bArray == null)
                return;

            fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray);
            btPrint.SetStatusEvent(fileContent);
            /*
            byte[] bArray1 = TSDUtils.CustomEncodingClass.Encoding.GetBytes(fileContent);
            int pos = bArray1.Length;

            string barcode = datarow.Barcode.ToString("00000000000000");
            if (fileContent.IndexOf("<<<GOODS_ATTRIBUTE_001>>>") > -1)
                fileContent = fileContent.Replace("<<<GOODS_ATTRIBUTE_001>>>", barcode);

            for (int i = 1; i < datarow.Table.Columns.Count; i++)
            {
                string strAttr = string.Format("<<<GOODS_ATTRIBUTE_{0}>>>", i.ToString("000"));
                if (fileContent.IndexOf(strAttr) > -1)
                    fileContent = fileContent.Replace(strAttr, datarow[i].ToString());
            }
            bArray1 = TSDUtils.CustomEncodingClass.Encoding.GetBytes(fileContent);

            byte[] bArray2 = new byte[bArray.Length - pos + bArray1.Length];
            System.Array.Copy(bArray1, 0, bArray2, 0, bArray1.Length);
            System.Array.Copy(bArray, pos, bArray2, bArray1.Length, bArray.Length - pos);
            
            fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray2);*/
            byte[] bArray2 = ReplaceAttr(bArray, datarow);
            fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray2);
            btPrint.SetStatusEvent(fileContent);
            return;
            if (btPrint.Connected)
            {
                btPrint.Print(/*fileContent*/bArray2);
            }
            {
                
                btPrint.ConnToPrinter(Program.Settings.TypedSettings[0].BTPrinterAddress);
                if (btPrint.Connected)
                {
                    btPrint.Print(/*fileContent*/bArray2);
                }
                
            }
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     ProductsDataSet ds = new ProductsDataSet();
     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;
 }
Пример #4
0
        private byte[] ReplaceAttr(byte[] bArray, ProductsDataSet.ProductsTblRow datarow)
        {
            List<byte> tempList = new List<byte>();
            List<byte> outArray = new List<byte>();
            for (int i = 0; i < bArray.Length; i++)
            {
                if (i < bArray.Length + 2 &&
                    bArray[i] == Convert.ToByte('<') &&
                    bArray[i + 1] == Convert.ToByte('<') &&
                    bArray[i + 2] == Convert.ToByte('<'))
                {
                    while (i < bArray.Length &&
                    bArray[i] != Convert.ToByte('>') &&
                    bArray[i - 1] != Convert.ToByte('>') &&
                    bArray[i - 2] != Convert.ToByte('>')

                        )
                    {
                        tempList.Add(bArray[i]);
                        i++;
                    }
                    Byte[] bArrTmp = new byte[tempList.Count];

                    tempList.CopyTo(bArrTmp);
                    tempList.Clear();
                    string atrName = TSDUtils.CustomEncodingClass.Encoding.GetString(bArrTmp).Replace("<","");
                    string atrCode = atrName.Replace("GOODS_ATTRIBUTE_", "");
                    int colId = -1;
                    try
                    {
                        colId = int.Parse(atrCode)+1;
                        //atrName = "Test";
                        if (datarow.Table.Columns[colId].DataType == typeof(string) ||
                            datarow.Table.Columns[colId].DataType == typeof(long) ||
                            datarow.Table.Columns[colId].DataType == typeof(int) ||
                            datarow.Table.Columns[colId].DataType == typeof(byte))
                        {
                            bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                datarow[colId].ToString());
                        }

                        if (datarow.Table.Columns[colId].DataType == typeof(DateTime))
                        {
                            bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                ((DateTime)datarow[colId]).ToString(dateFormat));
                        }
                        else
                            bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                datarow[colId].ToString());

                    }
                    catch { 
                    }

                    

                    outArray.AddRange(bArrTmp);
                    i += 2;
                }
                else
                {
                    outArray.Add(bArray[i]);
                }
            }
            return outArray.ToArray();
        }