Example #1
0
 protected void Insertbtn_Click(object sender, EventArgs e)
 {
     PDS.InsertParameters["ProductName"].DefaultValue  = ((TextBox)GridView1.FooterRow.FindControl("txtProductName")).Text;
     PDS.InsertParameters["ProductPrice"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtProductPrice")).Text;
     PDS.InsertParameters["ProductStock"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtProductStock")).Text;
     PDS.Insert();
 }
Example #2
0
        int cgcsgid = 0x02b90025;         // the above 2 OR'd together


        /// <summary>
        /// Process a 3270 Write Structured Field command
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="start"></param>
        /// <param name="bufferLength"></param>
        /// <returns></returns>
        public PDS WriteStructuredField(byte[] buffer, int start, int bufferLength)
        {
            int  fieldlen;
            int  cp         = start;
            bool first      = true;
            PDS  rv         = PDS.OkayNoOutput;
            PDS  rvThis     = PDS.OkayNoOutput;
            bool badCommand = false;

            // Skip the WSF command itself.
            cp++;
            bufferLength--;

            // Interpret fields.
            while (bufferLength > 0)
            {
                if (first)
                {
                    telnet.Trace.trace_ds(" ");
                }
                else
                {
                    telnet.Trace.trace_ds("< WriteStructuredField ");
                }

                first = false;

                // Pick out the field length.
                if (bufferLength < 2)
                {
                    telnet.Trace.trace_ds("error: single byte at end of message\n");
                    return((rv != PDS.OkayNoOutput) ? rv : PDS.BadCommand);
                }

                fieldlen = (buffer[cp] << 8) + buffer[cp + 1];

                if (fieldlen == 0)
                {
                    fieldlen = bufferLength;
                }

                if (fieldlen < 3)
                {
                    telnet.Trace.trace_ds("error: field length %d too small\n",
                                          fieldlen);
                    return((rv != PDS.OkayNoOutput) ? rv : PDS.BadCommand);
                }

                if ((int)fieldlen > bufferLength)
                {
                    telnet.Trace.trace_ds("error: field length %d exceeds remaining message length %d\n",
                                          fieldlen, bufferLength);
                    return((rv != PDS.OkayNoOutput) ? rv : PDS.BadCommand);
                }

                // Dispatch on the ID.
                switch (buffer[cp + 2])
                {
                case Codes.ReadPartition:
                    telnet.Trace.trace_ds("ReadPartition");
                    rvThis = ReadPart(CloneBytes(buffer, cp, fieldlen), (int)fieldlen);
                    break;

                case Codes.EraseReset:
                    telnet.Trace.trace_ds("EraseReset");
                    rvThis = EraseReset(CloneBytes(buffer, cp, fieldlen), (int)fieldlen);
                    break;

                case Codes.SetReplyMode:
                    telnet.Trace.trace_ds("SetReplyMode");
                    rvThis = SetReplyMode(CloneBytes(buffer, cp, fieldlen), (int)fieldlen);
                    break;

                case Codes.CreatePartition:
                    telnet.Trace.trace_ds("CreatePartition");
                    rvThis = CreatePartition(CloneBytes(buffer, cp, fieldlen), (int)fieldlen);
                    break;

                case Codes.OutboundDS:
                    telnet.Trace.trace_ds("OutboundDS");
                    rvThis = OutboundDS(CloneBytes(buffer, cp, fieldlen), (int)fieldlen);
                    break;

                default:
                    telnet.Trace.trace_ds("unsupported ID 0x%02x\n", buffer[cp + 2]);
                    rvThis = PDS.BadCommand;
                    break;
                }

                //Accumulate errors or output flags.
                //One real ugliness here is that if we have already generated some output, then we have already positively
                //acknowledged the request, so if we fail here, we have no way to return the error indication.
                if (rvThis < 0)
                {
                    badCommand = true;
                }
                else
                {
                    rv = (PDS)(rv | rvThis);
                }

                // Skip to the next field.
                cp           += fieldlen;
                bufferLength -= fieldlen;
            }

            if (first)
            {
                telnet.Trace.trace_ds(" (null)\n");
            }

            if (badCommand && rv == PDS.OkayNoOutput)
            {
                return(PDS.BadCommand);
            }
            else
            {
                return(rv);
            }
        }
        /// <summary>
        /// Using the map from ip address to fixture number, assigns the specified relationship to
        /// this LightSystem. This align's this system configuration with a previous configuration,
        /// so that previous configuration's addressing can be used.
        /// </summary>
        /// <param name="ipToFixtureNo"></param>
        /// <returns>A list of IP addresses that aren't detected on the current network</returns>
        public IEnumerable<String> SetFixtureAddresses(IDictionary<String, int> ipToFixtureNo )
        {
            int max = ipToFixtureNo.Values.Max() + 1 + _pdss.Count;
            ipToFixtureNo = new Dictionary<string, int>(ipToFixtureNo);

            PDS[] newPDSs = new PDS[max];
            List<int> missing = new List<int>(Enumerable.Range(0,max).Except(ipToFixtureNo.Values));

            foreach (var pds in _pdss)
            {
                String ipAddress = pds.EndPoint.Address.ToString();
                if (ipToFixtureNo.ContainsKey(ipAddress))
                {
                    newPDSs[ipToFixtureNo[ipAddress]] = pds;
                    ipToFixtureNo.Remove(ipAddress);
                }
                else
                {
                    newPDSs[missing[0]] = pds;
                    missing.RemoveAt(0);
                }
            }
            foreach (var i in ipToFixtureNo)
            {
                newPDSs[i.Value] = new NoOpPDS(Enumerable.Repeat(50,8).ToArray(), IPAddress.Parse(i.Key));
            }
            //This assumes that there are no missing values in the input list (or at least that for each missing value
            //there is an item now that didn't exist before. Likely will be a source of problems in the future.
            _pdss = new List<PDS>(newPDSs.TakeWhile(p => p != null));

            return ipToFixtureNo.Keys;
        }
Example #4
0
 public void AddPDS(PDS pds)
 {
     _pdss.Add(pds);
 }