Exemple #1
0
        private bool ExecuteTransaction(string ItemKey)
        {
            string update = "";

            try
            {
                if (_fstiClient.ProcessId(myItem, null))
                {
                    // success, get the response and display it using a list box
                    listResult.Items.Add("Success:");
                    listResult.Items.Add("");
                    listResult.Items.Add(_fstiClient.CDFResponse);
                    update = "UPDATE _CAP_Shipment_Line SET [FSTI_TransactionStatus] = 1,[FSTI_Error] = 0" +
                             ",[FSTI_TransactionMessage] = '" + _fstiClient.CDFResponse + "' WHERE ItemKey=" + ItemKey;
                    Cliente_SQL.Execute_Command(update);
                    couterGood++;
                }
                else
                {
                    // failure, retrieve the error object
                    // and then dump the information in the list box
                    FSTIError itemError = _fstiClient.TransactionError;
                    DumpErrorObject(myItem, itemError);

                    update = "UPDATE _CAP_Shipment_Line SET [FSTI_TransactionStatus] = 1" +
                             ",[FSTI_Error] = 1" +
                             ",[FSTI_TransactionMessage] = 'Error: " + itemError.Description +// " Transaction: "+myItem.GetString(TransactionStringFormat.fsCDF)+
                             "' WHERE ItemKey=" + ItemKey;
                    Cliente_SQL.Execute_Command(update);
                    counterBad++;
                    errors.Add("Part Number: " + myItem.ItemNumber.Value.ToString() + " Error Message: " + itemError.Description);
                }
                return(false);
            }
            catch (Exception ex)
            {
                StopServer();


                string EmailTo = "*****@*****.**";
                string Subject = "FS Movements Error " + DateTime.Now.ToString("MM-dd-yyy hh-mm");;

                //AlternateView body=
                string Body = "Server Error: " + ex.Message;
                mail.CreateMessage(EmailTo, Subject, Body);
                mail.SendEmail();

                //MessageBox.Show(ex.Message,"Server Error");
                return(true);
            }
        }
Exemple #2
0
        private string FSTI_Log(string CFGResponse, string User, string Type, string Error)
        {
            Data_Base_MNG.SQL DBMNG = new Data_Base_MNG.SQL("capsp", "AmalgammaDB", "amalgamma", "capsonic");

            Error = Error.Replace("'", "");

            string query = "INSERT INTO Amal_FSTI_Log (Amal_User ,Amal_Trans_Type ,Amal_Trans_Response ,Time_Stamp ,Amal_CFGResponse) " +
                           "VALUES ('" + User + "','" + Type + "','" + Error + "',Getdate(),'" + CFGResponse + "')";

            DBMNG.Execute_Command(query);

            return(DBMNG.Error_Mjs);
        }
Exemple #3
0
        private static bool Enroll()
        {
            string query = "INSERT INTO [AssetList] " +
                           "([ServiceTag],[HostName],[HostIP],[OS],[OfficeVer],[UpdatedDate],[UserName],[AssetModel]) VALUES" +
                           "('" + ServiceTag + "','" + HostName + "','" + HostIP + "','" + OS + "','" + getMyOffice()[0] +
                           "',Getdate(),'" + UserName + "','" + Model + "')";

            Data_Base_MNG.SQL DBMG_SQL = new Data_Base_MNG.SQL("192.168.0.11", "ASSETS_INV", "sa", "6rzq4d1");

            if (!DBMG_SQL.Execute_Command(query))
            {
                string x = DBMG_SQL.Error_Mjs;
                return(false);
            }

            return(true);
        }
Exemple #4
0
        private static bool UpdateInfo()
        {
            string query = "UPDATE [ASSETS_INV].[dbo].[AssetList] " +
                           " SET [ServiceTag] = '" + ServiceTag + "'" +
                           "  ,[HostName] = '" + HostName + "'" +
                           " ,[HostIP] = '" + HostIP + "'" +
                           " ,[OS] = '" + OS + "'" +
                           " ,[OfficeVer] = '" + Office[0] + "'" +
                           " ,[UpdatedDate] = Getdate()" +
                           " ,[UserName] = '" + UserName + "'" +
                           " ,[AssetModel] = '" + Model + "'" +
                           " WHERE (ServiceTag= '" + ServiceTag + "')";

            Data_Base_MNG.SQL DBMG_SQL = new Data_Base_MNG.SQL("192.168.0.11", "ASSETS_INV", "sa", "6rzq4d1");
            if (!DBMG_SQL.Execute_Command(query))
            {
                string x = DBMG_SQL.Error_Mjs;
                return(false);
            }

            return(true);
        }
Exemple #5
0
        private void ProcessTransaction()
        {
            string fields = "";
            string user   = "";

            if (FSTI.AmalgammaFSTI_Initialization())
            {
                if (FSTI.AmalgammaFSTI_Logon())
                {
                    #region Processing
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        switch (dataGridView1.Rows[0].Cells[1].Value.ToString())
                        {
                        case "MORV":
                        {
                            #region DoMorv
                            fields = dataGridView1.Rows[i].Cells[2].Value.ToString();
                            user   = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            if (FSTI.AmalgammaFSTI_MORV00(fields, user))
                            {
                                listBox1.Items.Add("");
                                listBox1.Items.Add(">>" + DateTime.Now.ToString("MM/dd/yy hh:mm") + " Transaction precessed correctly - " + FSTI.CDFResponse.ToString());
                                string query = "UPDATE Amal_FSTI_Transactions " +
                                               " SET TransactionProcessedYN = 1 " +
                                               "    ,FSResponse = '" + FSTI.CDFResponse.ToString() + "'" +
                                               "    ,FSError = 0" +
                                               "    ,DateStampOut = GetDate()" +
                                               " WHERE (FSTI_Transaction_key=" + dataGridView1.Rows[i].Cells[0].Value.ToString() + ")";
                                DBMNG.Execute_Command(query);
                            }
                            else
                            {
                                listBox1.Items.Add("");
                                listBox1.Items.Add(">>" + DateTime.Now.ToString("MM/dd/yy hh:mm") + " Transaction Failed - Error:" + FSTI.Trans_Error_Msg + " Fields: " + fields);
                                listBox1.Items.AddRange(FSTI.DetailError.ToArray());
                                string error = FSTI.Trans_Error_Msg.Replace('\'', '"');
                                string query = "UPDATE Amal_FSTI_Transactions " +
                                               " SET TransactionProcessedYN = 1 " +
                                               "    ,FSResponse = '" + error + "'" +
                                               "    ,FSError = 1" +
                                               "    ,DateStampOut = GetDate()" +
                                               " WHERE (FSTI_Transaction_key=" + dataGridView1.Rows[i].Cells[0].Value.ToString() + ")";
                                DBMNG.Execute_Command(query);
                            }
                            #endregion
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                    }
                    #endregion
                    FSTI.AmalgammaFSTI_Stop();
                }
                else
                {
                    listBox1.Items.Add("");
                    listBox1.Items.Add(">>" + DateTime.Now.ToString("MM/dd/yy hh:mm") + " Error during Logon - " + FSTI.FSTI_ErrorMsg);
                    FSTI.AmalgammaFSTI_Stop();
                }
            }
            else
            {
                listBox1.Items.Add("");
                listBox1.Items.Add(">>" + DateTime.Now.ToString("MM/dd/yy hh:mm") + " Error during Initialization - " + FSTI.FSTI_ErrorMsg);
                FSTI.AmalgammaFSTI_Stop();
            }
            //FSTI.AmalgammaFSTI_Stop();
        }
Exemple #6
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();
        }