Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            string    query = "SELECT * FROM Amal_FSTI_Transactions WHERE (TransactionProcessedYN = 0)";
            int       rows  = dataGridView1.Rows.Count;
            DataTable table = DBMNG.Execute_Query(query);

            dataGridView1.DataSource = table;
            if (rows > 0)
            {
                ProcessTransaction();
            }
            timer1.Enabled = true;
        }
Example #2
0
        private void MakeExtractionFiles()
        {
            DataTable table = null;
            string    query = "";

            //JadeItemMaster
            query = "SELECT * FROM _CAP_Jade_ItemMaster";
            table = null;
            table = DBMNG_FS.Execute_Query(query);
            Table2File(table, Jade_ItemMaster + ".csv");
            listBox2.Items.Add("");
            listBox2.Items.Add(DateTime.Now.ToString() + Jade_ItemMaster + ".csv was created succesfully.");

            //JadeItemFCSTMap
            query = "SELECT * FROM _CAP_Jade_Item_VendorFCSTs";
            table = null;
            table = DBMNG_FS.Execute_Query(query);
            Table2File(table, Jade_ItemFCSTMap + ".csv");
            listBox2.Items.Add("");
            listBox2.Items.Add(DateTime.Now.ToString() + Jade_ItemFCSTMap + ".csv was created succesfully.");

            //JadePOREQ
            query = "SELECT * FROM _CAP_Jade_PORequests";
            table = null;
            table = DBMNG_FS.Execute_Query(query);
            Table2File(table, Jade_POREQ + ".csv");
            listBox2.Items.Add("");
            listBox2.Items.Add(DateTime.Now.ToString() + Jade_POREQ + ".csv was created succesfully.");

            //JadeVendorMaster
            query = "SELECT * FROM _CAP_Jade_VendorMaster";
            table = null;
            table = DBMNG_FS.Execute_Query(query);
            Table2File(table, Jade_VendorMaster + ".csv");
            listBox2.Items.Add("");
            listBox2.Items.Add(DateTime.Now.ToString() + Jade_VendorMaster + ".csv was created succesfully.");
        }
Example #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            string query = "SELECT _CAP_Shipment_Header.ShipmentNumber, _CAP_Shipment_Header.ShipmentType, _CAP_Shipment_Header.ShipmentStatus " +
                           ", _CAP_Shipment_Line.ItemNumber, _CAP_Shipment_Line.StockRoomFrom, _CAP_Shipment_Line.BinFrom, _CAP_Shipment_Line.ItemUM " +
                           ", _CAP_Shipment_Line.InventoryCat, _CAP_Shipment_Line.InventoryQTY, _CAP_Shipment_Line.FSTI_TransactionStatus " +
                           ", _CAP_Shipment_Line.FSTI_TransactionMessage, _CAP_Shipment_Line.StockRoomTo, _CAP_Shipment_Line.BinTo " +
                           ", _CAP_Shipment_Line.CapShipmentLineKey, _CAP_Shipment_Line.CapShipmentHeaderKey, _CAP_Shipment_Line.ItemKey " +
                           "FROM _CAP_Shipment_Header INNER JOIN _CAP_Shipment_Line ON _CAP_Shipment_Header.CapShipmentHeadertKey = " +
                           "_CAP_Shipment_Line.CapShipmentHeaderKey " +
                           "WHERE     (_CAP_Shipment_Line.FSTI_TransactionStatus = 0) AND (_CAP_Shipment_Header.ShipmentType = 'Close') " +
                           "AND (_CAP_Shipment_Header.ShipmentStatus = 'Shipped')  AND (_CAP_Shipment_Line.IsFSExternal = 0)";
            //string query = "SELECT * FROM _CAP_Shipment_Line";

            string query2 = "SELECT     _CAP_Shipment_Line.CapShipmentHeaderKey, _CAP_Shipment_Line.ItemNumber, _CAP_Shipment_Line.InventoryQTY, _CAP_Shipment_Line.StockRoomFrom, " +
                            " _CAP_Shipment_Line.BinFrom, _CAP_Shipment_Line.InventoryCat, _CAP_Shipment_Line.StockRoomTo, _CAP_Shipment_Line.BinTo,  " +
                            " _CAP_Shipment_Line.IsFSExternal, _CAP_Shipment_Line.FSTI_Error, _CAP_Shipment_Line.FSTI_TransactionStatus,  " +
                            " _CAP_Shipment_Line.FSTI_TransactionMessage, _CAP_Shipment_Line.ItemKey " +
                            "   FROM         _CAP_Shipment_Header INNER JOIN " +
                            "                         _CAP_Shipment_Line ON _CAP_Shipment_Header.CapShipmentHeadertKey = _CAP_Shipment_Line.CapShipmentHeaderKey " +
                            "   WHERE     (_CAP_Shipment_Header.ShipmentNumber = N'PRIMERA-072213') AND (_CAP_Shipment_Line.IsFSExternal = 0) AND (_CAP_Shipment_Line.FSTI_Error = 0)";

            table = new DataTable();
            table = Cliente_SQL.Execute_Query(query);

            if (table.Rows.Count != dataGridView1.Rows.Count)
            {
                dataGridView1.DataSource = table;
            }
            else
            {
                DataTable DGV = (DataTable)dataGridView1.DataSource;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    for (int j = 0; j < table.Columns.Count; j++)
                    {
                        if (table.Rows[i][j].ToString() == DGV.Rows[i][j].ToString())
                        {
                            //MessageBox.Show("Prueba");
                        }
                        else
                        {
                            i = table.Rows.Count;
                            j = table.Columns.Count;
                            dataGridView1.DataSource = table;
                        }
                    }
                }
            }
            //dataGridView1.Rows[0];


            bool ServerError = false;

            FSTI_Proceed = true;

            if (table.Rows.Count != 0)
            {
                if (Proceed_trans == true)
                {
                    if (FSTI_Proceed == true)
                    {
                        if (FS_Initialize_Client())
                        {
                            if (_fstiClient.IsLogonRequired)
                            {
                                FS_Login_Client();
                            }
                            errors.Clear();
                            counterBad = 0;
                            couterGood = 0;
                            for (int i = 0; i < table.Rows.Count; i++)
                            {
                                if (!ServerError)
                                {
                                    ServerError = proceed(i);
                                }
                            }
                            string EmailTo = "[email protected],[email protected]";
                            string Subject = "FS Movements " + DateTime.Now.ToString("MM-dd-yyy hh-mm");;

                            //AlternateView body=
                            string Body   = "";
                            string Header = "Succesful: " + couterGood + " Fail: " + counterBad + Environment.NewLine + Environment.NewLine;
                            for (int k = 0; k < errors.Count; k++)
                            {
                                Body = Body + errors[k] + Environment.NewLine;
                            }

                            AlternateView HTMLbody = AlternateView.CreateAlternateViewFromString(Header + Body);
                            mail = null;
                            mail = new TOOLS.Email();
                            mail.CreateMessageHTML(EmailTo, Subject, HTMLbody);
                            mail.SendEmail();
                        }
                        FS_Close_Client();
                    }
                }
            }

            timer1.Start();
        }
Example #4
0
        /*
         * bool FS_Initialize_Client()
         * {
         *  if (!FSTI_initialized)
         *  {
         *      try
         *      {
         *          _fstiClient = new FSTIClient();
         *
         *          // call InitializeByConfigFile
         *          // second parameter == true is to participate in unified logon
         *          // third parameter == false, no support for impersonation is needed
         *
         *          _fstiClient.InitializeByConfigFile(textConfig.Text, true, false);
         *
         *          FSTI_initialized = true;
         *
         *          // Since this program is participating in unified logon, need to
         *          // check if a logon is required.
         *
         *          if (_fstiClient.IsLogonRequired)
         *          {
         *              // Logon is required, enable the logon button
         *              FSTI_Login.Enabled = true;
         *              FSTI_Login.Focus();
         *          }
         *          else
         *          {
         *              // Logon is not required (because of unified logon), enable the SubmitItem button
         *              //FSTI_Logout.Enabled = true;
         *              //FSTI_Logout.Focus();
         *
         *              Server_Start.Enabled = true;
         *              FSTI_CloseClient.Enabled = true;
         *
         *          }
         *          // Disable the Initialize button
         *          FSTI_Ini.Enabled = false;
         *          return true;
         *
         *      }
         *      catch (FSTIApplicationException exception)
         *      {
         *          //MessageBox.Show(exception.Message, "FSTIApplication Exception");
         *
         *
         *          string EmailTo = "*****@*****.**";
         *          string Subject = "FS Movements Error " + DateTime.Now.ToString("MM-dd-yyy hh-mm"); ;
         *
         *          //AlternateView body=
         *          string Body = "Server Error: " + exception.Message;
         *          mail.CreateMessage(EmailTo, Subject, Body);
         *          mail.SendEmail();
         *
         *          _fstiClient.Terminate();
         *          _fstiClient = null;
         *          return false;
         *      }
         *  }
         *
         *  return true;
         * }
         * private void FS_Login_Client()
         * {
         *  string message = null;     // used to hold a return message, from the logon
         *  int status;         // receives the return value from the logon call
         *  if (!FSTI_loged)
         *  {
         *      status = _fstiClient.Logon(FS_User.Text, FS_Pass.Text, ref message);
         *      if (status > 0)
         *      {
         *          MessageBox.Show("Invalid user id or password");
         *      }
         *      else
         *      {
         *          FSTI_Login.Enabled = false;
         *          Server_Start.Enabled = true;
         *          FSTI_CloseClient.Enabled = true;
         *          FSTI_loged = true;
         *      }
         *  }
         * }
         * private void FS_Close_Client()
         * {
         *  if (!HangFS.Checked)
         *  {
         *      timer1.Stop();
         *      Server_Start.Enabled = true;
         *      Server_Stop.Enabled = false;
         *
         *      if (_fstiClient != null)
         *      {
         *          _fstiClient.Terminate();
         *          _fstiClient = null;
         *      }
         *      FSTI_Ini.Enabled = true;
         *      FSTI_CloseClient.Enabled = false;
         *      FSTI_initialized = false;
         *      FSTI_loged = false;
         *  }
         * }
         */
        #endregion

        #region Eventos Server Configuration
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            string update = "";

            string query = "SELECT _CAP_Shipment_Header.ShipmentNumber, _CAP_Shipment_Header.ShipmentType, _CAP_Shipment_Header.ShipmentStatus " +
                           ", _CAP_Shipment_Line.ItemNumber, _CAP_Shipment_Line.StockRoomFrom, _CAP_Shipment_Line.BinFrom, _CAP_Shipment_Line.ItemUM " +
                           ", _CAP_Shipment_Line.InventoryCat, _CAP_Shipment_Line.InventoryQTY, _CAP_Shipment_Line.FSTI_TransactionStatus " +
                           ", _CAP_Shipment_Line.FSTI_TransactionMessage, _CAP_Shipment_Line.StockRoomTo, _CAP_Shipment_Line.BinTo " +
                           ", _CAP_Shipment_Line.CapShipmentLineKey, _CAP_Shipment_Line.CapShipmentHeaderKey, _CAP_Shipment_Line.ItemKey, _CAP_Shipment_Line.LotNo " +
                           "FROM _CAP_Shipment_Header INNER JOIN _CAP_Shipment_Line ON _CAP_Shipment_Header.CapShipmentHeadertKey = " +
                           "_CAP_Shipment_Line.CapShipmentHeaderKey " +
                           "WHERE     (_CAP_Shipment_Line.FSTI_TransactionStatus = 0) AND (_CAP_Shipment_Header.ShipmentType = 'Close') " +
                           "AND (_CAP_Shipment_Header.ShipmentStatus = 'Shipped')  AND (_CAP_Shipment_Line.IsFSExternal = 0)";

            //string query = "SELECT * FROM _CAP_Shipment_Line";

            //string query2 = "SELECT     _CAP_Shipment_Line.CapShipmentHeaderKey, _CAP_Shipment_Line.ItemNumber, _CAP_Shipment_Line.InventoryQTY, _CAP_Shipment_Line.StockRoomFrom, "+
            //          " _CAP_Shipment_Line.BinFrom, _CAP_Shipment_Line.InventoryCat, _CAP_Shipment_Line.StockRoomTo, _CAP_Shipment_Line.BinTo,  "+
            //          " _CAP_Shipment_Line.IsFSExternal, _CAP_Shipment_Line.FSTI_Error, _CAP_Shipment_Line.FSTI_TransactionStatus,  "+
            //          " _CAP_Shipment_Line.FSTI_TransactionMessage, _CAP_Shipment_Line.ItemKey " +
            //          "   FROM         _CAP_Shipment_Header INNER JOIN "+
            //          "                         _CAP_Shipment_Line ON _CAP_Shipment_Header.CapShipmentHeadertKey = _CAP_Shipment_Line.CapShipmentHeaderKey "+
            //          "   WHERE     (_CAP_Shipment_Header.ShipmentNumber = N'PRIMERA-072213') AND (_CAP_Shipment_Line.IsFSExternal = 0) AND (_CAP_Shipment_Line.FSTI_Error = 0)";

            table = new DataTable();
            table = Cliente_SQL.Execute_Query(query);

            if (table.Rows.Count != dataGridView1.Rows.Count)
            {
                dataGridView1.DataSource = table;
            }
            else
            {
                DataTable DGV = (DataTable)dataGridView1.DataSource;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    for (int j = 0; j < table.Columns.Count; j++)
                    {
                        if (table.Rows[i][j].ToString() == DGV.Rows[i][j].ToString())
                        {
                            //MessageBox.Show("Prueba");
                        }
                        else
                        {
                            i = table.Rows.Count;
                            j = table.Columns.Count;
                            dataGridView1.DataSource = table;
                        }
                    }
                }
            }
            //dataGridView1.Rows[0];


            bool ServerError = false;

            FSTI_Proceed = true;

            if (table.Rows.Count != 0)
            {
                try
                {
                    if (Proceed_trans == true)
                    {
                        if (FSTI_Proceed == true)
                        {
                            //if (FS_Initialize_Client())
                            #region Initialization
                            if (FSTI.AmalgammaFSTI_Initialization())
                            {
                                #region FSTI Login
                                if (FSTI.AmalgammaFSTI_Logon())
                                {
                                    #region FSTI Transaccion
                                    errors.Clear();
                                    counterBad = 0;
                                    couterGood = 0;
                                    for (int i = 0; i < table.Rows.Count; i++)
                                    {
                                        //if (!ServerError)
                                        //{
                                        //    proceed(i);
                                        //    //ServerError = FSTI.;
                                        //}

                                        if (proceed(i))
                                        {
                                            ProcessingLog("Transaction ended Susccesfully: " + FSTI.CDFResponse, "info");

                                            update = "UPDATE _CAP_Shipment_Line SET [FSTI_TransactionStatus] = 1,[FSTI_Error] = 0" +
                                                     ",[FSTI_TransactionMessage] = '" + FSTI.CDFResponse + "' WHERE CapShipmentLineKey=" + table.Rows[i]["CapShipmentLineKey"].ToString();
                                            Cliente_SQL.Execute_Command(update);
                                            couterGood++;
                                        }
                                        else
                                        {
                                            if (DB_IN_USE != FSTI.Trans_Error_Msg)
                                            {
                                                ProcessingLog("Transaction Fail: Error Message:" + FSTI.Trans_Error_Msg + " CDF: " + FSTI.CDFResponse, "error");

                                                update = "UPDATE _CAP_Shipment_Line SET [FSTI_TransactionStatus] = 1" +
                                                         ",[FSTI_Error] = 1" +
                                                         ",[FSTI_TransactionMessage] = 'Error: " + FSTI.Trans_Error_Msg.Replace("'", "\"") +// " Transaction: "+myItem.GetString(TransactionStringFormat.fsCDF)+
                                                         "' WHERE CapShipmentLineKey=" + table.Rows[i]["CapShipmentLineKey"].ToString();
                                                Cliente_SQL.Execute_Command(update);
                                                counterBad++;
                                                errors.Add("Part Number: " + table.Rows[i]["ItemNumber"].ToString() + " Error Message: " + FSTI.Trans_Error_Msg);
                                            }
                                            else
                                            {
                                                ProcessingLog("Transaction Fail: " + table.Rows[i]["ItemNumber"].ToString() + " - " + FSTI.Trans_Error_Msg, "warning");
                                            }
                                        }
                                    }
                                    string EmailTo = "[email protected],[email protected]";
                                    string Subject = "FS Movements " + DateTime.Now.ToString("MM-dd-yyy hh-mm");;

                                    //AlternateView body=
                                    string Body   = "";
                                    string Header = "Succesful: " + couterGood + " Fail: " + counterBad + Environment.NewLine + Environment.NewLine;
                                    for (int k = 0; k < errors.Count; k++)
                                    {
                                        Body = Body + errors[k] + Environment.NewLine;
                                    }

                                    //AlternateView HTMLbody = AlternateView.CreateAlternateViewFromString(Header + Body);
                                    //mail = null;
                                    //mail = new TOOLS.Email();
                                    //mail.CreateMessageHTML(EmailTo, Subject, HTMLbody);
                                    //mail.SendEmail();
                                    #endregion
                                }
                                else
                                {
                                    //MessageBox.Show(FSTI.ErrorMsg, "Error During Login");
                                    ProcessingLog("FSTI-Error During Login - " + FSTI.FSTI_ErrorMsg, "error");
                                    FSTI_Error_Flag = true;
                                }
                            }
                            #endregion
                            else
                            {
                                //MessageBox.Show(FSTI.ErrorMsg, "Error During FSTI Inicialitation");
                                ProcessingLog("FSTI-Error During FSTI Inicialitation - " + FSTI.FSTI_ErrorMsg, "error");
                                FSTI_Error_Flag = true;
                            }
                            //FS_Close_Client();
                            FSTI.AmalgammaFSTI_Stop();
                            #endregion
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProcessingLog("FSTI-Error Exeption - " + ex.Message, "error");
                    //MessageBox.Show(ex.Message, "Error FSTI Exeption");
                    FSTI.AmalgammaFSTI_Stop();
                }
            }

            timer1.Start();
        }