示例#1
0
        public wsMDSmartMoverV2B.ResponseArray fcnSubmitRequest(wsMDSmartMoverV2B.RequestArray reqArray, string serializeToFile)
        {
            //check parameters
            if (reqArray == null)
                throw new ArgumentNullException("reqArray cannot be Null");
            else if (reqArray.Record.Length <= 0)
                throw new ArgumentException("RequestArray does not have any records");
            else if (serializeToFile == string.Empty)
                throw new ArgumentException("serializeToFile parameter must be null or a non-empty string");

            //get timeout and retry settings
            int timeout = 30;
            int retries = 10;

            //submit request
            wsMDSmartMoverV2B.ResponseArray respArray = null;
            int retryCount = 0;
            mdSmartMover.Timeout = timeout * 1000;
            bool found = false;

            do
            {
                try
                {
                    respArray = mdSmartMover.DoSmartMover(reqArray);
                    if (respArray.Fault.Code.StartsWith("WSE00"))
                    {
                        //InternalError. Likely due to traffic spike so keep retrying.
                        //clsErr.subLogErr("frmAddStd_3.fcnSubmitRequest",null);
                        retryCount++;
                        found = false;
                    }
                    else
                    {
                        found = true;

                        //serialize if requested
                        if (serializeToFile != null)
                        {
                            System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(respArray.GetType());
                            System.IO.StreamWriter sw = new System.IO.StreamWriter(serializeToFile, true);
                            ser.Serialize(sw, respArray);
                            sw.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    retryCount++;
                    clsErr.subLogErr("frmAddStd_3.fcnSubmitRequest", ex);
                }
            } while (retryCount < retries && found == false);

            return respArray;
        }
示例#2
0
        private bool fcnProcessResponseArray(wsMDSmartMoverV2B.ResponseArray respArray)
        {
            //check for Fault
            if (respArray.Fault.Code != "")
            {
                //handle the error
                MessageBox.Show("Error! \n" + respArray.Fault.Desc);
                return false;
            }

            string strSQL = "";

            using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
            {
                conDB.Open();

                using (OleDbCommand cmdDB = new OleDbCommand())
                {
                    cmdDB.Connection = conDB;

                    int count = Int32.Parse(respArray.TotalRecords);
                    for (int x = 0; x < count; x++)
                    {
                        string strAddress = respArray.Record[x].Address.Address1 + " " + respArray.Record[x].Address.Suite + " " + respArray.Record[x].Address.PrivateMailBox;
                        string strStatus = "";
                        if (respArray.Record[x].Address.Result.Status.Code == "0")
                            strStatus = "Error";
                        else if (respArray.Record[x].Address.Result.Status.Code == "1")
                            strStatus = "Moved";
                        else if (respArray.Record[x].Address.Result.Status.Code == "2")
                            strStatus = "Standardized";

                        string strCity = respArray.Record[x].Address.City.Name;
                        string strState = respArray.Record[x].Address.State.Abbreviation;
                        string strZip = respArray.Record[x].Address.Zip + "-" + respArray.Record[x].Address.Plus4;
                        string strErrorCode = respArray.Record[x].Address.Result.Error.Code;
                        string strErrorDesc = respArray.Record[x].Address.Result.Error.Description;
                        string strMoveDate = respArray.Record[x].Address.Move.EffectiveDate;
                        string strMoveReturnCode = respArray.Record[x].Address.Move.Return.Code;
                        string strMoveReturnDesc = respArray.Record[x].Address.Move.Return.Description;
                        string strMoveTypeCode = respArray.Record[x].Address.Move.Type.Code;
                        string strMoveTypeDesc = respArray.Record[x].Address.Move.Type.Description;

                        long lngRecordID = Convert.ToInt32(respArray.Record[x].RecordID);

                        //add/edit record in results table
                        strSQL = "SELECT tblRecordCert.blnReconciled, " +
                                    "tblRecordCert.lngRecordID, " +
                                    "tblRecordCert.dteProcessed, " +
                                    "tblRecordCert.strErrorCode, tblRecordCert.strErrorDesc, tblRecordCert.strStatus, tblRecordCert.strMoveDate, tblRecordCert.strMoveReturnCode, tblRecordCert.strMoveReturnDesc, tblRecordCert.strMoveTypeCode, tblRecordCert.strMoveTypeDesc, tblRecordCert.strListName, tblRecordCert.strAddress, tblRecordCert.strCity, tblRecordCert.strState, tblRecordCert.strZip, tblRecordCert.strTicketID " +
                                "FROM tblRecordCert " +
                                "WHERE tblRecordCert.lngRecordID=" + lngRecordID;

                        cmdDB.Parameters.Clear();
                        cmdDB.CommandText = strSQL;

                        using (OleDbDataAdapter daIRCert = new OleDbDataAdapter())
                        {
                            daIRCert.SelectCommand = cmdDB;
                            using (OleDbCommandBuilder cbdIRCert = new OleDbCommandBuilder(daIRCert))
                            {
                                using (DataSet dsIRCert = new DataSet())
                                {
                                    daIRCert.Fill(dsIRCert);

                                    using (DataTable dtIRCert = dsIRCert.Tables[0])
                                    {
                                        DataRow rowToUpdate;

                                        bool blnAdd = false;

                                        if (dtIRCert.Rows.Count > 0)
                                            rowToUpdate = dtIRCert.Rows[0];
                                        else
                                        {
                                            rowToUpdate = dtIRCert.NewRow();
                                            blnAdd = true;
                                        }

                                        rowToUpdate["blnReconciled"] = false;
                                        rowToUpdate["lngRecordID"] = lngRecordID;
                                        rowToUpdate["dteProcessed"] = DateTime.Now;
                                        rowToUpdate["strErrorCode"] = strErrorCode;
                                        rowToUpdate["strErrorDesc"] = strErrorDesc;
                                        rowToUpdate["strStatus"] = strStatus;
                                        rowToUpdate["strMoveDate"] = strMoveDate;
                                        rowToUpdate["strMoveReturnCode"] = strMoveReturnCode;
                                        rowToUpdate["strMoveReturnDesc"] = strMoveReturnDesc;
                                        rowToUpdate["strMoveTypeCode"] = strMoveTypeCode;
                                        rowToUpdate["strMoveTypeDesc"] = strMoveTypeDesc;
                                        rowToUpdate["strListName"] = strListName;
                                        rowToUpdate["strAddress"] = strAddress;
                                        rowToUpdate["strCity"] = strCity;
                                        rowToUpdate["strState"] = strState;
                                        rowToUpdate["strZip"] = strZip;
                                        //rowToUpdate["strTicketID"] = clsNav.objAddStd_2.txtTicketID.Text;

                                        if (blnAdd) dtIRCert.Rows.Add(rowToUpdate);

                                        daIRCert.Update(dtIRCert);
                                    }
                                }
                            }
                        }
                    }
                }

                conDB.Close();
            }

            return true;
        }