public long Prepare(string n)
        {
            var u = -(preps.Length ?? 0) - 2;

            preps += (u, n);
            return(u);
        }
 public void ActOnEffect(SDict dict)
 {
     if (dict.keys.Contains(s))
     {
         if (type == EffectorType.Add)
         {
             dict.SetValue(s, dict.GetValue(s) + f);
         }
         if (type == EffectorType.Divide)
         {
             dict.SetValue(s, dict.GetValue(s) / f);
         }
         if (type == EffectorType.Minus)
         {
             dict.SetValue(s, dict.GetValue(s) - f);
         }
         if (type == EffectorType.Multiply)
         {
             dict.SetValue(s, dict.GetValue(s) * f);
         }
         if (type == EffectorType.Equalize)
         {
             dict.SetValue(s, f);
         }
     }
 }
Beispiel #3
0
 public NodeEditorDat(string _path, List <DNode> _nodes, int _connectionIDCount, ConnectionDict dict, SDict propertyDictionary)
 {
     savePath          = _path;
     nodes             = _nodes;
     connectionIDCount = _connectionIDCount;
     connections       = dict;
     propertyDict      = propertyDictionary;
 }
 public void SendUids(SDict <long, string> u)
 {
     Write(Types.SNames);
     PutInt(u.Length);
     for (var b = u.First(); b != null; b = b.Next())
     {
         PutLong(b.Value.Item1);
         PutString(b.Value.Item2);
     }
 }
Beispiel #5
0
        // We peek at the table expression to compute the set of columns of the join
        static SQuery _Join(ReaderBase f)
        {
            f.GetInt();
            var st       = f.buf.pos;
            var d        = SDict <int, (long, string)> .Empty;
            var c        = SDict <int, Serialisable> .Empty;
            var nms      = SDict <string, long> .Empty;
            var left     = f._Get() as SQuery ?? throw new StrongException("Query expected");
            var outer    = f.GetInt() == 1;
            var joinType = (JoinType)f.GetInt();
            var right    = f._Get() as SQuery ?? throw new StrongException("Query expected");
            var ab       = left.Display.First();
            var uses     = SDict <long, long> .Empty;

            if (joinType.HasFlag(JoinType.Named))
            {
                var n = f.GetInt();
                for (var i = 0; i < n; i++)
                {
                    uses += (f.GetLong(), f.GetLong());
                }
            }
            var k = 0;

            for (var lb = left.cpos.First(); ab != null && lb != null; ab = ab.Next(), lb = lb.Next())
            {
                var col = lb.Value;
                var u   = ab.Value.Item2;
                d   += (k, u);
                c   += (k, col.Item2);
                nms += (u.Item2, u.Item1);
                k++;
            }
            ab = right.Display.First();
            for (var rb = right.cpos.First(); ab != null && rb != null; ab = ab.Next(), rb = rb.Next())
            {
                var u = ab.Value.Item2;
                var n = u.Item2;
                if (joinType == JoinType.Natural && nms.Contains(n))
                {
                    continue;
                }
                if (uses.Contains(u.Item1))
                {
                    continue;
                }
                var col = rb.Value;
                d += (k, u);
                c += (k, col.Item2);
                k++;
            }
            f.buf.pos = st;
            return(new SQuery(Types.STableExp, d, c));
        }
Beispiel #6
0
        public readonly SDict <long, long> uses; // Item1 is for RIGHT, Item2 for LEFT
        public SJoin(ReaderBase f) : base(Types.STableExp, _Join(f))
        {
            left     = f._Get() as SQuery ?? throw new StrongException("Query expected");
            outer    = f.GetInt() == 1;
            joinType = (JoinType)f.GetInt();
            right    = f._Get() as SQuery ?? throw new StrongException("Query expected");
            var n   = f.GetInt();
            var on  = SList <SExpression> .Empty;
            var us  = SDict <long, long> .Empty;
            var tr  = (STransaction)f.db;
            var lns = SDict <string, long> .Empty;

            for (var b = left.Display.First(); b != null; b = b.Next())
            {
                lns += (b.Value.Item2.Item2, b.Value.Item2.Item1);
            }
            var rns = SDict <string, long> .Empty;

            for (var b = right.Display.First(); b != null; b = b.Next())
            {
                var nm = b.Value.Item2.Item2;
                if (joinType == JoinType.Natural && lns.Contains(nm))
                {
                    us += (b.Value.Item2.Item1, lns[nm]);
                }
                rns += (nm, b.Value.Item2.Item1);
            }
            if (joinType.HasFlag(JoinType.Named))
            {
                for (var i = 0; i < n; i++)
                {
                    var nm = tr.uids[f.GetLong()];
                    if (!(lns.Contains(nm) && rns.Contains(nm)))
                    {
                        throw new StrongException("name " + nm + " not present in Join");
                    }
                    us += (rns[nm], lns[nm]);
                }
            }
            else if (!joinType.HasFlag(JoinType.Cross))
            {
                for (var i = 0; i < n; i++)
                {
                    var e = f._Get() as SExpression
                            ?? throw new StrongException("ON exp expected");
                    on += e;
                }
            }
            ons       = on;
            uses      = us;
            f.context = this;
        }
        public StrongConnect(string host, int port, string fn)
        {
            Socket?socket = null;

            try
            {
                IPEndPoint ep;
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                if (char.IsDigit(host[0]))
                {
                    IPAddress ip = IPAddress.Parse(host);
                    ep = new IPEndPoint(ip, port);
                    socket.Connect(ep);
                }
                else
                {
#if MONO1
                    var he = Dns.GetHostByName(hostName);
#else
                    IPHostEntry he = Dns.GetHostEntry(host);
#endif
                    for (int j = 0; j < he.AddressList.Length; j++)
                    {
                        try
                        {
                            IPAddress ip = he.AddressList[j];
                            ep = new IPEndPoint(ip, port);
                            socket.Connect(ep);
                            if (socket.Connected)
                            {
                                break;
                            }
                        }
                        catch (Exception) { }
                    }
                }
            }
            catch (Exception)
            {
            }
            if (socket == null || !socket.Connected)
            {
                throw new Exception("No connection to " + host + ":" + port);
            }
            asy = new ClientStream(this, socket);
            var wtr = asy.wtr;
            wtr.PutString(fn);
            asy.Flush();
            asy.Receive();
            preps = SDict <long, string> .Empty;
        }
        public void CreateTable(string n)
        {
            var un  = Prepare(n);
            var wtr = asy.wtr;

            wtr.SendUids(preps);
            wtr.Write(Types.SCreateTable);
            wtr.PutLong(un);
            wtr.PutInt(0);
            wtr.PutInt(0);
            var b = asy.Receive();

            preps = SDict <long, string> .Empty;
        }
Beispiel #9
0
    private void Download(string path)
    {
        nodes.Clear();
        connections.ClearValues();
        properties.ClearValues();

        string        json = File.ReadAllText(Application.dataPath + "/" + path);
        NodeEditorDat dat  = JsonUtility.FromJson <NodeEditorDat> (json);

        nodes             = dat.nodes;
        connectionIDCount = dat.connectionIDCount;
        connections       = dat.connections;
        properties        = dat.propertyDict;
    }
 public bool passCheck(SDict newD)
 {
     dict = newD;
     if (available(propertyName))
     {
         if (checkType == propertyCheck.GreaterThan)
         {
             if (dict.GetValue(propertyName) > value)
             {
                 return(true);
             }
         }
         else if (checkType == propertyCheck.EqualTo)
         {
             if (dict.GetValue(propertyName) == value)
             {
                 return(true);
             }
         }
         else if (checkType == propertyCheck.GreaterOrEqual)
         {
             if (dict.GetValue(propertyName) >= value)
             {
                 return(true);
             }
         }
         else if (checkType == propertyCheck.LowerOrEqual)
         {
             if (dict.GetValue(propertyName) <= value)
             {
                 return(true);
             }
         }
         else if (checkType == propertyCheck.LowerThan)
         {
             if (dict.GetValue(propertyName) < value)
             {
                 return(true);
             }
         }
         else if (checkType == propertyCheck.NA)
         {
             return(true);
         }
         return(false);
     }
     return(false);
 }
Beispiel #11
0
        SQuery Query(SDict <int, string> als, SDict <int, Serialisable> cp)
        {
            var tb = TableExp(als, cp);
            var wh = SList <Serialisable> .Empty;
            var tt = Sym.WHERE;
            var n  = 0;

            for (; lxr.tok == tt; n++)
            {
                Next(); tt = Sym.AND;
                wh        += (Conjunct(), n);
            }
            SQuery sqry = (wh.Length == 0)?tb:new SSearch(tb, wh);

            if (lxr.tok != Sym.GROUPBY)
            {
                return(sqry);
            }
            Next();
            var gp = SDict <int, string> .Empty;

            for (n = 0; lxr.tok == Sym.ID; n++)
            {
                gp += (n, ((SString)lxr.val).str);
                Next();
                if (lxr.tok != Sym.COMMA)
                {
                    break;
                }
                Next();
            }
            var h = SList <Serialisable> .Empty;

            if (lxr.tok == Sym.HAVING)
            {
                for (n = 0; ; n++)
                {
                    Next();
                    h += (Conjunct(), n);
                    if (lxr.tok != Sym.AND)
                    {
                        break;
                    }
                }
            }
            return(new SGroupQuery(sqry, sqry.display, sqry.cpos,
                                   new Context(sqry.names, null), gp, h));
        }
        internal SDbObject SName(string s)
        {
            long uid;

            if (names.Contains(s))
            {
                uid = names[s];
            }
            else
            {
                uid    = --_uid;
                names += (s, uid);
                uids  += (uid, s);
            }
            return(new SDbObject(Types.SName, uid));
        }
Beispiel #13
0
 static void ShowRow(SDict <string, string> r, List <Column> cols)
 {
     for (int j = 0; j < cols.Count; j++)
     {
         Console.Write("|");
         var c = cols[j];
         var v = r.Lookup(c.name) ?? "";
         Console.Write(v);
         for (int k = 0; k < c.width - v.Length; k++)
         {
             Console.Write(" ");
         }
     }
     Console.Write("|");
     Console.WriteLine();
 }
Beispiel #14
0
    private void Inspector()
    {
        if (properties == null)
        {
            properties = new SDict();
        }


        if (clickedThisFrame)
        {
            if (constantInspectorRect.Contains(Event.current.mousePosition))
            {
                clickedInspector = true;
            }
        }
        else
        {
            if (clickedInspector)
            {
                if (constantInspectorRect.Contains(Event.current.mousePosition))
                {
                    clickedInspector = true;
                }
                else
                {
                    clickedInspector = false;
                }
            }
        }

        if (drawInspector)
        {
            inspectorRect         = r(width - 250, 0 + heading.height, 250, height);
            constantInspectorRect = r(width - 250, 0 + heading.height, 250, height);
            DrawRectBox(inspectorRect, "");
        }
        else
        {
            inspectorRect         = r(0, 0, 0, 0);
            constantInspectorRect = r(0, 0, 0, 0);
        }



        InspectorEvents();
    }
Beispiel #15
0
        static void Show(StrongConnect c, DocArray da)
        {
            List <Column>       cols  = new List <Column>();                                         // of Column
            SDict <string, int> names = SDict <string, int> .Empty;
            SDict <int, SDict <string, string> > rows = SDict <int, SDict <string, string> > .Empty; // of string[]

            for (var b = c.description.First(); b != null; b = b.Next())
            {
                names = names + (b.Value.Item2, b.Value.Item1);
                cols.Add(new Column(b.Value.Item2, b.Value.Item2.Length));
            }
            for (int i = 0; i < da.items.Count; i++)
            {
                var dc  = da[i];
                var row = SDict <string, string> .Empty;
                for (var j = 0; j < dc.fields.Count; j++)
                {
                    var f = dc.fields[j];
                    if (f.Key.StartsWith("_"))
                    {
                        continue;
                    }
                    if (!names.Contains(f.Key))
                    {
                        throw new Exception("Unexpected column " + f.Key);
                    }
                    var k = names.Lookup(f.Key);
                    var s = f.Value.ToString();
                    if (s.Length > cols[k].width)
                    {
                        cols[k].width = s.Length;
                    }
                    row = row + (f.Key, s);
                }
                rows = rows + (rows.Length.Value, row);
            }
            DrawLine(cols);
            ShowHeads(cols);
            DrawLine(cols);
            for (var j = 0; j < rows.Length.Value; j++)
            {
                ShowRow(rows.Lookup(j), cols);
            }
            DrawLine(cols);
        }
Beispiel #16
0
        public DocArray Get(Serialisable tn)
        {
            asy.Write(Types.DescribedGet);
            tn.Put(asy);
            asy.Flush();
            var b = asy.ReadByte();

            if (b == (byte)Types.Exception)
            {
                inTransaction = false;
                asy.GetException();
            }
            if (b == (byte)Types.Done)
            {
                description = SDict <int, string> .Empty;
                var n = asy.rbuf.GetInt();
                for (var i = 0; i < n; i++)
                {
                    description += (i, asy.rbuf.GetString());
                }
                return(new DocArray(asy.rbuf.GetString()));
            }
            throw new Exception("??");
        }
		protected SNode GetDBRow()
		{
			SNode nhead = ParseOne();
			// get header
			SObject head = nhead as SObject;
			if (head == null)
				throw new ParseException("The DBRow header isn't present...");

			if (head.Name != "blue.DBRowDescriptor")
				throw new ParseException("Bad descriptor name");

			STuple fields = head.Members[0].Members[1].Members[0] as STuple;

			int len = GetLength();
			byte[] olddata = Reader.ReadBytes(len);

			List<byte> newdata = new List<byte>();
			rle_unpack(olddata, newdata);
			SNode body = new SDBRow(17, newdata);

			CacheFileReader blob = new CacheFileReader(newdata.ToArray());

			SDict dict = new SDict(999999); // TODO: need dynamic sized dict
			int step = 1;
			while (step < 6)
			{
				foreach (SNode field in fields.Members)
				{
					SNode fieldName = field.Members[0];
					SInt fieldType = field.Members[1] as SInt;
					int fieldTypeInt = fieldType.Value;

					byte boolcount = 0;
					byte boolbuf = 0;
					SNode obj = null;
					switch (fieldTypeInt)
					{
						case 2: // 16bit int
							if(step == 3)
								obj = new SInt(blob.ReadShort());
							break;
						case 3: // 32bit int
							if (step == 2)
								obj = new SInt(blob.ReadInt());
							break;
						case 4:
							obj = new SReal(blob.ReadFloat());
							break;
						case 5: // double
							if(step == 1)
								obj = new SReal(blob.ReadDouble());
							break;
						case 6: // currency
							if (step == 1)
								obj = new SLong(blob.ReadLong());
							break;
						case 11: // boolean
							if (step == 5)
							{
								if (boolcount == 0)
								{
									boolbuf = blob.ReadByte();
									boolcount = 0x1;
								}
								if (boolbuf != 0 && boolcount != 0)
									obj = new SInt(1);
								else
									obj = new SInt(0);
								boolcount <<= 1;
							}
							break;
						case 16:
							obj = new SInt(blob.ReadByte());
							break;
						case 17:
							goto case 16;
						case 18: // 16bit int
							goto case 2;
						case 19: // 32bit int
							goto case 3;
						case 20: // 64bit int
							goto case 6;
						case 21: // 64bit int
							goto case 6;
						case 64: // timestamp
							goto case 6;
						case 128: // string types
						case 129:
						case 130:
							obj = new SString("I can't parse strings yet - be patient");
							break;
						default:
							throw new ParseException("Unhandled ADO type " + fieldTypeInt);
					}

					if (obj != null)
					{
						dict.AddMember(obj);
						dict.AddMember(fieldName.Clone());
					}
				}

				step++;
			}

			SNode fakerow = new STuple(3);
			fakerow.AddMember(head);
			fakerow.AddMember(body);
			fakerow.AddMember(dict);
			return fakerow;
		}
        /** Method:  Load histogram for calculation */
        void IConvolution.LoadHistogram(double min, double max, double totFreqs, double range, int maxClasses, SDict <int, double> freqs, double nConv)
        {
            Histogram hist = new Histogram();

            hist.LoadHist(min, max, totFreqs, range, maxClasses, freqs);
            this.nConv     = nConv;
            this.convMean  = hist.Mean * nConv;
            this.convStDev = hist.StDev * Math.Sqrt(nConv);
        }
        /** Method:  Load a Histogram for calculation with restriction of classes
         * n -  number (real) of convolutions */
        void IConvolution.LoadHistogram(double min, double max, double totFreqs, double range, int maxClasses, SDict <int, double> freqs, double n)
        {
            //set properties
            Histogram histogram = new Histogram();

            histogram.LoadHist(min, max, totFreqs, range, maxClasses, freqs);
            this.originalHistogram = histogram;
            this.mean  = originalHistogram.Mean;
            this.stDev = originalHistogram.StDev;
            this.n     = n;

            //scale classes
            if (maxClasses > 0 && maxClasses < histogram.Freqs.Count)
            {
                this.histogram = new Histogram(maxClasses);
                this.histogram.LoadHist(originalHistogram);
            }
            else
            {
                this.histogram = this.originalHistogram;
            }
        }
Beispiel #20
0
        /** Method:  Load histogram for calculation
         * hist -  histogram for calculation
         * n -  number of convolutions */
        void IConvolution.LoadHistogram(double min, double max, double totFreqs, double range, int maxClasses, SDict <int, double> freqs, double n)
        {
            Histogram hist = new Histogram();

            hist.LoadHist(min, max, totFreqs, range, maxClasses, freqs);
            ((IConvolution)this).LoadData(hist.GetRawData(), n);
        }
Beispiel #21
0
 public SJoin(SQuery lf, bool ou, JoinType jt, SQuery rg, SList <SExpression> on,
              SDict <long, long> us, SDict <int, (long, string)> d, SDict <int, Serialisable> c)
		protected SNode ParseOne()
		{
			EStreamCode check;
			byte isshared = 0;
			SNode thisobj = null;
			SDBRow lastDbRow = null;

			try
			{
				byte type = Reader.ReadByte();
				check = (EStreamCode)(type & 0x3f);
				isshared = (byte)(type & 0x40);
			}
			catch (EndOfFileException)
			{
				return null;
			}

			#region EStreamCode Switch
			switch (check)
			{
				case EStreamCode.EStreamStart:
					break;
				case EStreamCode.ENone:
					thisobj = new SNone();
					break;
				case EStreamCode.EString:
					thisobj = new SString(Reader.ReadString(Reader.ReadByte()));
					break;
				case EStreamCode.ELong:
					thisobj = new SLong(Reader.ReadLong());
					break;
				case EStreamCode.EInteger:
					thisobj = new SInt(Reader.ReadInt());
					break;
				case EStreamCode.EShort:
					thisobj = new SInt(Reader.ReadShort());
					break;
				case EStreamCode.EByte:
					thisobj = new SInt(Reader.ReadByte());
					break;
				case EStreamCode.ENeg1Integer:
					thisobj = new SInt(-1);
					break;
				case EStreamCode.E0Integer:
					thisobj = new SInt(0);
					break;
				case EStreamCode.E1Integer:
					thisobj = new SInt(1);
					break;
				case EStreamCode.EReal:
					thisobj = new SReal(Reader.ReadDouble());
					break;
				case EStreamCode.E0Real:
					thisobj = new SReal(0);
					break;
				case EStreamCode.E0String:
					thisobj = new SString(null);
					break;
				case EStreamCode.EString3:
					thisobj = new SString(Reader.ReadString(1));
					break;
				case EStreamCode.EString4:
					goto case EStreamCode.EString;
				case EStreamCode.EMarker:
					thisobj = new SMarker((byte)GetLength());
					break;
				case EStreamCode.EUnicodeString:
					goto case EStreamCode.EString;
				case EStreamCode.EIdent:
					thisobj = new SIdent(Reader.ReadString(GetLength()));
					break;
				case EStreamCode.ETuple:
					{
						int length = GetLength();
						thisobj = new STuple((uint)length);
						Parse(thisobj, length);
						break;
					}
				case EStreamCode.ETuple2:
					goto case EStreamCode.ETuple;
				case EStreamCode.EDict:
					{
						int len = (GetLength() * 2);
						SDict dict = new SDict((uint)len);
						thisobj = dict;
						Parse(dict, len);
						break;
					}
				case EStreamCode.EObject:
					thisobj = new SObject();
					Parse(thisobj, 2);
					break;
				case EStreamCode.ESharedObj:
					thisobj = ShareGet(GetLength());
					break;
				case EStreamCode.EChecksum:
					thisobj = new SString("checksum");
					Reader.ReadInt();
					break;
				case EStreamCode.EBoolTrue:
					thisobj = new SInt(1);
					break;
				case EStreamCode.EBoolFalse:
					thisobj = new SInt(0);
					break;
				case EStreamCode.EObject22:
					{
						SObject obj = new SObject();
						thisobj = obj;
						Parse(thisobj, 1);

						string oclass = obj.Name;
						if (oclass == "dbutil.RowList")
						{
							SNode row;
							while ((row = ParseOne()) != null)
								obj.AddMember(row);
						}
						break;
					}
				case EStreamCode.EObject23:
					goto case EStreamCode.EObject22;
				case EStreamCode.E0Tuple:
					thisobj = new STuple(0);
					break;
				case EStreamCode.E1Tuple:
					thisobj = new STuple(1);
					Parse(thisobj, 1);
					break;
				case EStreamCode.E0Tuple2:
					goto case EStreamCode.E0Tuple;
				case EStreamCode.E1Tuple2:
					goto case EStreamCode.E1Tuple;
				case EStreamCode.EEmptyString:
					thisobj = new SString(string.Empty);
					break;
				case EStreamCode.EUnicodeString2:
					/* Single unicode character */
					thisobj = new SString(Reader.ReadString(2));
					break;
				case EStreamCode.ECompressedRow:
					thisobj = GetDBRow();
					break;
				case EStreamCode.ESubstream:
					{
						int len = GetLength();
						CacheFileReader readerSub = new CacheFileReader(Reader, len);
						SSubStream ss = new SSubStream(len);
						thisobj = ss;
						CacheFileParser sp = new CacheFileParser(readerSub);
						sp.Parse();
						for (int i = 0; i < sp.Streams.Count; i++)
							ss.AddMember(sp.Streams[i].Clone());

						Reader.Seek(readerSub.Position, SeekOrigin.Begin);
						break;
					}
				case EStreamCode.E2Tuple:
					thisobj = new STuple(2);
					Parse(thisobj, 2);
					break;
				case EStreamCode.EString2:
					goto case EStreamCode.EString;
				case EStreamCode.ESizedInt:
					switch (Reader.ReadByte())
					{
						case 8:
							thisobj = new SLong(Reader.ReadLong());
							break;
						case 4:
							thisobj = new SInt(Reader.ReadInt());
							break;
						case 3:
							// The following seems more correct than the forumla used.
							// int value = (Reader.Char() << 16) + (Reader.ReadByte());
							thisobj = new SInt((Reader.ReadByte()) + (Reader.ReadByte() << 16));
							break;
						case 2:
							thisobj = new SInt(Reader.ReadShort());
							break;
					}
					break;
				case (EStreamCode)0x2d:
					if (Reader.ReadByte() != (byte)0x2d)
						throw new ParseException("Didn't encounter a double 0x2d where one was expected at " + (Reader.Position - 2));
					else if (lastDbRow != null)
						lastDbRow.IsLast = true;
					return null;
				case 0:
					break;
				default:
					throw new ParseException("Can't identify type " + String.Format("{0:x2}", (int)check) +
											" at position " + String.Format("{0:x2}", Reader.Position) + " limit " + Reader.Length);
			}
			#endregion

			if (thisobj == null)
				throw new ParseException("no thisobj in parseone");

			if (isshared != 0)
			{
				if (thisobj == null)
					throw new ParseException("shared flag but no obj");
				ShareAdd(thisobj);
			}

			return thisobj;
		}
Beispiel #23
0
        private void Init()
        {
            XmlDocument doc = null;

            doc = new XmlDocument();
            doc.Load("city.xml");
            XmlNodeList provinceNodeList = doc.SelectNodes("/address/province");
            if (provinceNodeList != null)
            {
                foreach (XmlNode provinceNode in provinceNodeList)
                {
                    string province = provinceNode.Attributes["name"].Value;
                    if (!_citys.ContainsKey(province))
                        _citys.Add(province, new ArrayList());

                    comboBox_provice.Items.Add(province);
                    comboBox_regProvice.Items.Add(province);
                    comboBox_aftersalesProvice.Items.Add(province);

                    XmlNodeList cityNodeList = provinceNode.SelectNodes("city");
                    if (cityNodeList != null)
                    {
                        foreach (XmlNode cityNode in cityNodeList)
                        {
                            string city = cityNode.Attributes["name"].Value;

                            _citys[province].Add(city);
                        }
                    }
                }
                comboBox_provice.SelectedIndex = 0;
                comboBox_regProvice.SelectedIndex = 0;
                comboBox_aftersalesProvice.SelectedIndex = 0;
            }
            doc = null;

            doc = new XmlDocument();
            doc.Load("dict.xml");
            XmlNodeList rowNodeList = doc.SelectNodes("/dictlist/dict/row");
            if (rowNodeList != null)
            {
                foreach (XmlNode rowNode in rowNodeList)
                {
                    SDict di = new SDict();
                    di.id = int.Parse(rowNode.Attributes["TYPE_ID"].Value);
                    di.name = rowNode.Attributes["DICT_NAME"].Value;
                    di.code = rowNode.Attributes["DICT_CODE"].Value;
                    di.rcode = rowNode.Attributes["RELEVANCE_CODE"].Value;

                    if (!_dict.ContainsKey(di.id))
                        _dict.Add(di.id, new Dictionary<string, SDict>());
                    if (!_dict[di.id].ContainsKey(di.code))
                        _dict[di.id].Add(di.code, di);
                }
            }
            doc = null;

            Dictionary<string, SDict> tdi = null;
            // 经济性质
            if (_dict.TryGetValue(14, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_economyNature.Items.Add(item.Value.name);
                }
                comboBox_economyNature.SelectedIndex = 0;
            }
            tdi = null;
            // 供应商类型
            if (_dict.TryGetValue(11, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_supplierType.Items.Add(item.Value.name);
                }
                comboBox_supplierType.SelectedIndex = 0;
            }
            tdi = null;
            // 采购方式
            if (_dict.TryGetValue(6, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_purchaseType.Items.Add(item.Value.name);
                }
                comboBox_purchaseType.SelectedIndex = 0;
            }
            tdi = null;

            // 信用等级
            if (_dict.TryGetValue(13, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_creditLevel.Items.Add(item.Value.name);
                }
                comboBox_creditLevel.SelectedIndex = 0;
            }
            tdi = null;
            // 开户银行
            if (_dict.TryGetValue(12, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_bank.Items.Add(item.Value.name);
                }
                //comboBox_bank.SelectedIndex = 0;
            }
            tdi = null;
            // 售后类型
            if (_dict.TryGetValue(17, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_aftersalesType.Items.Add(item.Value.name);
                }
                comboBox_aftersalesType.SelectedIndex = 0;
            }
            tdi = null;
            // 运输车类型
            if (_dict.TryGetValue(18, out tdi))
            {
                foreach (KeyValuePair<string, SDict> item in tdi)
                {
                    comboBox_transportType.Items.Add(item.Value.name);
                }
                comboBox_transportType.SelectedIndex = 0;
            }
            tdi = null;

            this.comboBox_natualTaxPay.SelectedIndex = 0;
            this.comboBox_landTaxPay.SelectedIndex = 0;
            this.comboBox_bankHasIllegal.SelectedIndex = 0;
            this.comboBox_bankHasPay.SelectedIndex = 0;
            this.comboBox_purchaseSuccese.SelectedIndex = 0;
        }
Beispiel #24
0
        SQuery TableExp(SDict <int, string> als, SDict <int, Serialisable> cp)
        {
            if (lxr.tok == Sym.LPAREN)
            {
                SQuery r;
                Next();
                if (lxr.tok == Sym.SELECT)
                {
                    r = (SQuery)Select();
                }
                else
                {
                    r = TableExp(SDict <int, string> .Empty, SDict <int, Serialisable> .Empty);
                }
                Mustbe(Sym.RPAREN);
                return(r);
            }
            var id = MustBeID();
            var tb = new STable(id.str);

            if (lxr.tok == Sym.ID && lxr.val != null)
            {
                var alias = ((SString)lxr.val).str;
                Next();
                tb = new SAliasedTable(tb, alias);
            }
            var jt = SJoin.JoinType.None;

            if (lxr.tok == Sym.COMMA)
            {
                Next();
                jt = SJoin.JoinType.Cross;
            }
            else if (lxr.tok == Sym.CROSS)
            {
                Next();
                Mustbe(Sym.JOIN);
                jt = SJoin.JoinType.Cross;
            }
            else
            {
                if (lxr.tok == Sym.NATURAL)
                {
                    Next();
                    jt |= SJoin.JoinType.Natural;
                    Mustbe(Sym.JOIN);
                }
                else
                {
                    if (lxr.tok == Sym.INNER)
                    {
                        Next();
                        jt |= SJoin.JoinType.Inner;
                    }
                    else
                    {
                        if (lxr.tok == Sym.LEFT)
                        {
                            Next();
                            jt |= SJoin.JoinType.Left;
                        }
                        else if (lxr.tok == Sym.RIGHT)
                        {
                            Next();
                            jt |= SJoin.JoinType.Right;
                        }
                        else if (lxr.tok == Sym.FULL)
                        {
                            Next();
                            jt |= (SJoin.JoinType.Left | SJoin.JoinType.Right);
                        }
                        if (jt != SJoin.JoinType.None && lxr.tok == Sym.OUTER)
                        {
                            Next();
                        }
                    }
                    if (jt != SJoin.JoinType.None)
                    {
                        Mustbe(Sym.JOIN);
                    }
                }
            }
            if (jt != SJoin.JoinType.None)
            {
                var on = SList <SExpression> .Empty;
                var ra = TableExp(SDict <int, string> .Empty, SDict <int, Serialisable> .Empty);
                var da = SDict <int, string> .Empty;
                var ca = SDict <int, Serialisable> .Empty;
                var na = SDict <string, Serialisable> .Empty;
                var us = SList <string> .Empty;
                if ((jt & (SJoin.JoinType.Cross | SJoin.JoinType.Natural)) == 0)
                {
                    if (lxr.tok == Sym.USING)
                    {
                        Next();
                        jt |= SJoin.JoinType.Named;
                        for (; ;)
                        {
                            var v = lxr.val;
                            Mustbe(Sym.ID);
                            us += ((SString)v).str;
                            if (lxr.tok == Sym.COMMA)
                            {
                                Next();
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        Mustbe(Sym.ON);
                        for (; ;)
                        {
                            var ex = Conjunct();
                            if (!(ex is SExpression e) || e.op != SExpression.Op.Eql ||
                                e.left.type != Types.SColumn ||
                                e.right.type != Types.SColumn)
                            {
                                throw new Exception("Column matching expression expected");
                            }
                            on += (SExpression)ex;
                            if (lxr.tok == Sym.AND)
                            {
                                Next();
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
                return(new SJoin(tb, false, jt, ra, on, us,
                                 da, ca, new Context(na, null)));
            }
            return(tb);
        }
Beispiel #25
0
 new SRObject(SDict <long, int> .Empty, SDict <string, int> .Empty,