Ejemplo n.º 1
0
        public override async Task <bool> process()
        {
            var    _xconn         = xmlMsgIn.Data.Element("connection");                                //get the connection data
            var    _parameters    = xmlMsgIn.Data.Element("parameterCollection").Elements("parameter"); //get the parameters list
            string _dataBase      = _xconn.Element("DataBase").Value.ToString();                        //get the database
            string _procedureName = xmlMsgIn.Data.Element("procedureName").Value.ToString();            // get the procedure name
            var    _server        = new cServer(_xconn.Element("server"));                              //create the server object from the connection data

            try
            {
                using (var _conn = new cAccesoDatosNet(_server, _dataBase)) //create the normal connection
                    using (var _sp = new SP(_conn, _procedureName))         // create the normal SP
                    {
                        _parameters.ToList().ForEach(p =>
                        {
                            _sp.AddParameterValue(p.Element("parameterName").Value.ToString(), p.Element("parameterValue").Value.ToString());
                        });                       //adds the parameters and the values to the sp from the parameter list
                        await _sp.ExecuteAsync(); //execute the sp

                        if (_sp.LastMsg.Substring(0, 2) != "OK")
                        {
                            throw new Exception(_sp.LastMsg);      //error message
                        }
                        XElement _msgOut = new XElement("result"); //create the msgout xml data
                        _msgOut.Add(_sp.XOutParameters.Root);      //adds the out parameters to the data
                        xmlMsgOut = new XDocument(_msgOut);        // returns
                    }
            }
            catch (Exception ex)
            {
                xmlMsgOut = new XDocument(new XElement("result", "ERROR: " + ex.Message));
            }
            MsgOut = xmlMsgOut.ToString();
            return(true);
        }
Ejemplo n.º 2
0
        public override async Task <bool> process()
        {
            var    _xconn    = xmlMsgIn.Data.Element("connection");           //get the connection data
            string _dataBase = _xconn.Element("DataBase").Value.ToString();   //get the database
            var    _server   = new cServer(_xconn.Element("server"));         //create the server object from the connection data
            string _sql      = xmlMsgIn.Data.Element("sql").Value.ToString(); //get the sql

            using (var _conn = new cAccesoDatosNet(_server, _dataBase))       //create the normal connection

                using (var _rs = new DynamicRS(_sql, _conn))                  // create the normal recordset
                {
                    try
                    {
                        await _rs.OpenAsync();             //execute the recordset

                        xmlMsgOut           = _rs.XMLData; //create the msgout xml data
                        xmlMsgOut.Root.Name = "result";
                    }
                    catch (Exception ex)
                    {
                        xmlMsgOut = XDocument.Parse((new XElement("result", "ERROR: " + ex.Message)).ToString()); //returns error
                    }
                }
            MsgOut = xmlMsgOut.ToString();
            return(true);
        }
Ejemplo n.º 3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(string.Format("This will print {0} unit labels. Are you sure?", txtQty.Text), "SIMPLISTICA", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int _labelInit = 0;

                txtPrinter.Text = Values.LabelPrinterAddress.ToString();

                using (var _conn = new cAccesoDatosNet(Values.gDatos.Server, "REPAIRS", Values.gDatos.User, Values.gDatos.Password))
                    using (var _sp = new SP(_conn, "pGetContador"))
                    {
                        _sp.AddParameterValue("@Contador", "");
                        _sp.AddParameterValue("@Serv", "");
                        _sp.AddParameterValue("@Codigo", cboService.Value + "_UNIT_ETIQ");
                        _sp.AddParameterValue("@Incremento", Convert.ToInt32(txtQty.Value));
                        _sp.Execute();
                        _labelInit = Convert.ToInt32(_sp.ReturnValues()["@Contador"]);
                    }

                if (txtCharacter.Text == "")
                {
                    throw (new Exception("Wrong character for labels."));
                }

                string _printerAddress    = "";
                int    _printerResolution = 0;
                using (var _RS = new DynamicRS(string.Format("select descripcion,cmp_varchar,cmp_integer from ETIQUETAS..datosEmpresa where codigo='{0}'", Values.LabelPrinterAddress), Values.gDatos))
                {
                    _RS.Open();
                    _printerAddress    = _RS["cmp_varchar"].ToString();
                    _printerResolution = Convert.ToInt32(_RS["cmp_integer"]);
                    //_printerType = _RS["descripcion"].ToString().Split('|')[0];
                }
                var _label     = new ZPLLabel(70, 32, 3, _printerResolution);
                var _unitLabel = new SingleBarcode(_label);

                //_label.addLine(35, 3, 0, "C", "", "[BC][UNITNUMBER]", 0, 2.5F, 1,true);
                //var _param = new Dictionary<string, string>();
                using (var _printer = new cRawPrinterHelper(_printerAddress))
                {
                    var _delimiterLabel = new ZPLLabel(_unitLabel.Label.width, _unitLabel.Label.height, 3, _unitLabel.Label.dpi);
                    delimiterLabel.delim(_delimiterLabel, "START UNIT LABELS", "-");
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                    //for (var i = _labelInit; i < _labelInit + Convert.ToInt32(txtQty.Value); i++)
                    for (var i = _labelInit + Convert.ToInt32(txtQty.Value) - 1; i >= _labelInit; i--)
                    {
                        _unitLabel.Parameters["VALUE"] = txtCharacter.Text + i.ToString().PadLeft(8, '0');
                        for (var j = 0; j < Convert.ToInt32(txtQtyLabel.Text); j++)
                        {
                            _printer.SendUTF8StringToPrinter(_unitLabel.ToString(), 1);
                        }
                    }
                    delimiterLabel.delim(_delimiterLabel, "END UNIT LABLES", "-");
                    _printer.SendUTF8StringToPrinter(_delimiterLabel.ToString(), 1);
                }
            }
        }
Ejemplo n.º 4
0
        // Add the results of a query to the current area
        public bool AddQuery(string pSQL, cAccesoDatosNet pConn, EspackFont pFont = null, bool pHideTitles = false)
        {
            using (var _rs = new DynamicRS(pSQL, pConn))
            {
                _rs.Open();
                if (_rs.RecordCount == 0)
                {
                    MessageBox.Show("The query returned no data.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                else
                {
                    Dictionary <string, List <string> > _matrix = new Dictionary <string, List <string> >();

                    foreach (var _item in _rs.Fields)
                    {
                        _matrix[_item.ToString()] = new List <string>();
                    }

                    int _col;

                    _rs.ToList().ForEach(_row =>
                    {
                        _col = 0;
                        _row.ItemArray.ToList().ForEach(_column =>
                        {
                            _matrix[_matrix.Keys.ToList()[_col]].Add(_column.ToString());
                            _col++;
                        });
                    });

                    foreach (var _key in _matrix.Keys)
                    {
                        Areas.Add(CurrentArea = new EspackPrintingArea(EnumDocumentZones.BODY, pFont, pDocking: EnumZoneDocking.RIGHTWARDS));

                        // Add current column title
                        if (!pHideTitles)
                        {
                            AddText(true, _key.ToString(), true);
                            CurrentArea.PermanentRows++;
                        }
                        // Add data for current column
                        foreach (var _item in _matrix[_key])
                        {
                            AddText(_item.ToString(), true);
                            CurrentArea.DataRows++;
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 5
0
        public void Source(string pSQL, cAccesoDatosNet pConn)
        {
            noChange = true;
            _SQL     = pSQL;
            _RS      = new DynamicRS(_SQL, pConn);
            _RS.Open();
            DataSource = null;
            DataSource = _RS.DataObject;

            if (_RS.FieldCount > 1)
            {
                DisplayMember = _RS.Fields[1];
            }
            ValueMember  = _RS.Fields[0];
            SelectedItem = null;
            noChange     = false;
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string pe;
            string pa;

            pe = IntToLetters(128);

            pa = IntToLettersRec(128);

            using (var _conn = new cAccesoDatosNet("DB01", "SISTEMAS", "sa", "5380"))
            {
                using (var _rs = new StaticRS("select UserCode,Name,Surname1,Surname2,EmailAddress from Users", _conn))
                {
                    _rs.Open();
                    _rs.SaveExcelFile(@"D:\text.xlsx");
                }
            }
        }
Ejemplo n.º 7
0
        public static object CreateObject(string objectClass, string objectType, object param1 = null, object param2 = null, string serial = null)
        {
            switch (objectClass)
            {
            case "Conn":
                object _conn;
                if (objectType == "Socks")
                {
                    _conn = new cAccesoDatosXML();
                }
                else
                {
                    _conn = new cAccesoDatosNet();
                }
                EspackCommServer.Server.Serial = serial;
                return(_conn);

            case "SP": if (objectType == "Socks")
                {
                    return(new SPXML((cAccesoDatosXML)param1, (string)param2));
                }
                else
                {
                    return(new SP((cAccesoDatosNet)param1, (string)param2));
                }

            case "RS": if (objectType == "Socks")
                {
                    return(new XMLRS((string)param1, (cAccesoDatosXML)param2));
                }
                else
                {
                    return(new DynamicRS((string)param1, (cAccesoDatosNet)param2));
                }

            default:
                return(null);
            }
        }
Ejemplo n.º 8
0
        public override async Task <bool> process()
        {
            XElement _xServer = xmlMsgIn.Data.Element("server");
            var      _server  = new cServer();

            _server.xServer = _xServer;
            var _conn = new cAccesoDatosNet(_server, xmlMsgIn.Data.Element("DataBase").Value);

            try
            {
                await _conn.ConnectAsync();

                xmlMsgOut = new XDocument(new XElement("result", "OK"));
            }
            catch (Exception ex)
            {
                xmlMsgOut = new XDocument(new XElement("result", "ERROR: " + ex.Message));
            }

            MsgOut = xmlMsgOut.ToString();
            return(true);
        }
Ejemplo n.º 9
0
 public SP_Controls(cAccesoDatosNet pConn, string pSPName = "") : base(pConn, pSPName)
 {
 }
Ejemplo n.º 10
0
 public DynamicRS_Controls(string Sql, cAccesoDatosNet Conn)
     : base(Sql, Conn)
 {
 }
Ejemplo n.º 11
0
        public async Task LaunchApp(bool temp = false)
        {
            //if (!Special && !External)
            //{
            //    SetStatus(AppBotStatus.PENDING_UPDATE);
            //    //if (!await CheckUpdated().ConfigureAwait(false))
            //    if (!await CheckUpdated(true))
            //    {
            //        Application.DoEvents();
            //        ActiveThreads++;
            //        var _thread = new cUpdaterThread(debugBox, ActiveThreads);
            //        // launch task not async
            //        await _thread.Process();
            //    }
            //    SetStatus(AppBotStatus.UPDATED);
            //}
            if (DBServer.HostName != gDatos.Server && DBServer.User != "procesos")
            {
                var _datos = new cAccesoDatosNet();
                _datos.User     = gDatos.User;
                _datos.Password = gDatos.Password;
                _datos.DataBase = gDatos.DataBase;
                _datos.Server   = DBServer.HostName;
                // check the password in the new server
                var _SP = new SP(_datos, "pLogOnUser");
                _SP.AddParameterValue("User", DBServer.User);
                _SP.AddParameterValue("Ticket", DBServer.Password);
                _SP.AddParameterValue("Origin", "LOGON_CS");
                try
                {
                    _SP.Execute();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\nIf you have recently changed your password, wait a couple of minutes before opening this app.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            string _tempPath = string.Format("{0}\\{1}", Path.GetTempPath(), this.Code);

            if (temp)
            {
                //copy to temp folder

                DirectoryInfo _dir = new DirectoryInfo(_tempPath);
                if (_dir.Exists)
                {
                    try
                    {
                        _dir.Delete(true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "\nIt looks like the application is already open.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                var _odir = new DirectoryInfo(LOCAL_PATH + Code + "/");
                _odir.DirectoryCopy(_tempPath);
                _tempPath = string.Format("{0}\\{1}", _tempPath, ExeName);
            }
            else
            {
                _tempPath = LocalPath;
            }
            // Use ProcessStartInfo class
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.UseShellExecute = false;
            startInfo.FileName        = _tempPath;
            startInfo.WindowStyle     = ProcessWindowStyle.Maximized;
            startInfo.Arguments       = string.Format("/srv={0} /db={1} /usr={2} /pwd={3} /loc={4} /app={5}{6}{7}", DBServer.IP.ToString(), DataBase, DBServer.User, DBServer.Password, "OUT", Name, External ? " /ext=1" : "", Code == "logon"?" /noxml=1":"");

            try
            {
                Process exeProcess = Process.Start(startInfo);
                OnAfterLaunch(new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }