Esempio n. 1
0
        public OPCodeGetResponse OPCodeGet(OPCodeGetRequest request)
        {
            OPCodeGetResponse response = new OPCodeGetResponse();

            try
            {
                //Request body-header object validation
                response.Errors = GetErrorDataListFromRequestTransactionHeader(request.TransactionHeader);
                if (response.Errors != null)
                {
                    response.TransactionHeader = new Data.v2.Common.Common.TransactionHeader();
                    return response;
                }
                response.Errors = GetErrorDataListFromRequest(request.OPCodeGet);
                if (response.Errors != null)
                {
                    response.TransactionHeader = request.TransactionHeader;
                    return response;
                }

                using (OPCode_Biz biz = new OPCode_Biz())
                {
                    response = biz.OPCodeGet(request);
                }
            }
            catch (Exception ex)
            {
                response.Errors = GetErrorDataListFromException(ex);
                WA.Standard.IF.Logger.Log.Log.RootLogger.ErrorFormat("OPCodeGetResponse Error {0}: ", ex);
            }

            return response;
        }
Esempio n. 2
0
        public OPCodeGetResponse OPCodeGet(OPCodeGetRequest request)
        {
            OPCodeGetResponse response = new OPCodeGetResponse();

            try
            {
                WA.Standard.IF.Logger.Log.Log.SaveXMLLog(0, request.TransactionHeader.DealerID, "WA OPCodeGetRequest XML", request);

                //Request body-header object validation
                response.Errors = GetErrorDataListFromRequestTransactionHeader(request.TransactionHeader);
                if (response.Errors != null)
                {
                    response.TransactionHeader = new Data.v2.Common.Common.TransactionHeader();
                }
                response.Errors = GetErrorDataListFromRequest(request.OPCodeGet);
                if (response.Errors != null)
                {
                    response.TransactionHeader = request.TransactionHeader;
                }

                if (response.Errors == null)
                {
                    using (OPCode_Biz biz = new OPCode_Biz())
                    {
                        response = biz.OPCodeGet(request);
                    }

                    WA.Standard.IF.Logger.Log.Log.SaveXMLLog(0, request.TransactionHeader.DealerID, "WA OPCodeGetResponse XML", response);
                }
            }
            catch (Exception ex)
            {
                response.Errors = GetErrorDataListFromException(ex);
                WA.Standard.IF.Logger.Log.Log.SaveErrorLog(null, "OPCodeGet", request, ex.Message, ex);
            }

            return response;
        }
Esempio n. 3
0
        public OPCodeGetResponse OPCodeGet(OPCodeGetRequest request)
        {
            OPCodeGetResponse response = new OPCodeGetResponse();

            //DMS information set by dealer information
            string proxypath = string.Format("{0}.{1}.{2}.{3}",
                request.TransactionHeader.DocumentVersion,
                request.TransactionHeader.DistributorID,
                request.TransactionHeader.DMSCode,
                request.TransactionHeader.DMSVersion);

            switch (proxypath)
            {
                case "v2.Common.WA.v2":
                    {
                        #region v2.Common.WA.v2 - Standard (Proxy Class Dll Name : _WA.Mapper.v2)

                        #region OPCodeGet Request Set

                        //Create proxy credential
                        NetworkCredential proxycredential = new NetworkCredential(request.TransactionHeader.Username, request.TransactionHeader.Password);

                        //Create proxy web service from dms web service with credential
                        _WA.Mapper.v2.OPCode.OPCode proxyws = new _WA.Mapper.v2.OPCode.OPCode(request.TransactionHeader.DMSServerUrl);
                        proxyws.Credentials = proxycredential;

                        //Create proxy request with opcodeget and transaction
                        _WA.Mapper.v2.OPCode.OPCodeGetRequest proxyrequest = new _WA.Mapper.v2.OPCode.OPCodeGetRequest();

                        //Create proxy transaction
                        _WA.Mapper.v2.OPCode.TransactionHeader proxytransactionheader = new _WA.Mapper.v2.OPCode.TransactionHeader();
                        if (request.TransactionHeader != null)
                        {
                            #region//TransactionHeader Set
                            proxytransactionheader.CountryID = request.TransactionHeader.CountryID;
                            proxytransactionheader.DealerID = request.TransactionHeader.DealerID;
                            proxytransactionheader.DistributorID = request.TransactionHeader.DistributorID;
                            proxytransactionheader.DMSCode = request.TransactionHeader.DMSCode;
                            proxytransactionheader.DMSServerUrl = request.TransactionHeader.DMSServerUrl;
                            proxytransactionheader.DMSVersion = request.TransactionHeader.DMSVersion;
                            proxytransactionheader.DocumentVersion = request.TransactionHeader.DocumentVersion;
                            proxytransactionheader.GroupID = request.TransactionHeader.GroupID;
                            proxytransactionheader.IneterfaceID = request.TransactionHeader.IneterfaceID;
                            proxytransactionheader.Password = request.TransactionHeader.Password;
                            proxytransactionheader.PollingToken = request.TransactionHeader.PollingToken;
                            proxytransactionheader.RequestPollingToken = request.TransactionHeader.RequestPollingToken;
                            proxytransactionheader.RequestType = request.TransactionHeader.RequestType;
                            proxytransactionheader.TransactionId = request.TransactionHeader.TransactionId;
                            proxytransactionheader.TransactionDateTimeLocal = request.TransactionHeader.TransactionDateTimeLocal;
                            proxytransactionheader.TransactionDateTimeUTC = request.TransactionHeader.TransactionDateTimeUTC;
                            proxytransactionheader.TransactionType = request.TransactionHeader.TransactionType;
                            proxytransactionheader.Username = request.TransactionHeader.Username;
                            proxytransactionheader.VenderTrackingCode = request.TransactionHeader.VenderTrackingCode;
                            proxyrequest.TransactionHeader = proxytransactionheader;
                            #endregion
                        }

                        //Create proxy opcodeget
                        _WA.Mapper.v2.OPCode.OPCodeGet proxyopcodeget = new _WA.Mapper.v2.OPCode.OPCodeGet();
                        if (request.OPCodeGet != null)
                        {
                            #region//OPCodeGet Set
                            proxyopcodeget.Category = request.OPCodeGet.Category;
                            proxyopcodeget.Code = request.OPCodeGet.Code;
                            proxyopcodeget.Description = request.OPCodeGet.Description;
                            proxyopcodeget.Engine = request.OPCodeGet.Engine;
                            proxyopcodeget.Make = request.OPCodeGet.Make;
                            proxyopcodeget.Mileage = request.OPCodeGet.Mileage;
                            proxyopcodeget.Model = request.OPCodeGet.Model;
                            proxyopcodeget.Year = request.OPCodeGet.Year;
                            proxyrequest.OPCodeGet = proxyopcodeget;
                            #endregion
                        }
                        #endregion

                        //Run proxy web method with proxy request
                        _WA.Mapper.v2.OPCode.OPCodeGetResponse proxyresponse = proxyws.OPCodeGet(proxyrequest);

                        //Mapping with Standard Interface Specification Object
                        if (proxyresponse != null)
                        {
                            if (proxyresponse.TransactionHeader != null)
                            {
                                #region//TransactionHeader Set
                                TransactionHeader transactionheader = new TransactionHeader();
                                transactionheader.CountryID = proxyresponse.TransactionHeader.CountryID;
                                transactionheader.DealerID = proxyresponse.TransactionHeader.DealerID;
                                transactionheader.DistributorID = proxyresponse.TransactionHeader.DistributorID;
                                transactionheader.DMSCode = proxyresponse.TransactionHeader.DMSCode;
                                transactionheader.DMSServerUrl = proxyresponse.TransactionHeader.DMSServerUrl;
                                transactionheader.DMSVersion = proxyresponse.TransactionHeader.DMSVersion;
                                transactionheader.DocumentVersion = proxyresponse.TransactionHeader.DocumentVersion;
                                transactionheader.GroupID = proxyresponse.TransactionHeader.GroupID;
                                transactionheader.IneterfaceID = proxyresponse.TransactionHeader.IneterfaceID;
                                transactionheader.Password = proxyresponse.TransactionHeader.Password;
                                transactionheader.PollingToken = proxyresponse.TransactionHeader.PollingToken;
                                transactionheader.RequestPollingToken = proxyresponse.TransactionHeader.RequestPollingToken;
                                transactionheader.RequestType = proxyresponse.TransactionHeader.RequestType;
                                transactionheader.TransactionId = proxyresponse.TransactionHeader.TransactionId;
                                transactionheader.TransactionDateTimeLocal = proxyresponse.TransactionHeader.TransactionDateTimeLocal;
                                transactionheader.TransactionDateTimeUTC = proxyresponse.TransactionHeader.TransactionDateTimeUTC;
                                transactionheader.TransactionType = proxyresponse.TransactionHeader.TransactionType;
                                transactionheader.Username = proxyresponse.TransactionHeader.Username;
                                transactionheader.VenderTrackingCode = proxyresponse.TransactionHeader.VenderTrackingCode;
                                response.TransactionHeader = transactionheader;
                                #endregion
                            }

                            //ResultMessage Set
                            if (proxyresponse.ResultMessage != null)
                            {
                                response.ResultMessage = GetResultMessageData(proxyresponse.ResultMessage.Code, proxyresponse.ResultMessage.Message);
                            }

                            if (proxyresponse.Errors != null)
                            {
                                //Error List Set
                                foreach (_WA.Mapper.v2.OPCode.Error proxyerror in proxyresponse.Errors)
                                {
                                    if (response.Errors != null)
                                        response.Errors.Add(GetErrorData(proxyerror.Code, proxyerror.Message));
                                    else
                                        response.Errors = GetErrorDataList(proxyerror.Code, proxyerror.Message);
                                }
                            }
                            else
                            {
                                #region //OPCodeGetResponse Set

                                if (proxyresponse.OPCodes != null && proxyresponse.OPCodes.Length > 0)
                                {
                                    response.OPCodes = new List<Data.v2.Common.OPCode.OPCode>();
                                    foreach (_WA.Mapper.v2.OPCode.OPCode1 proxyopcode in proxyresponse.OPCodes)
                                    {
                                        #region //OPCode Header
                                        Data.v2.Common.OPCode.OPCode opcode = new Data.v2.Common.OPCode.OPCode();
                                        opcode.Code = proxyopcode.Code;
                                        opcode.CorrectionLOP = proxyopcode.CorrectionLOP;
                                        opcode.CPSIND = proxyopcode.CPSIND;
                                        opcode.DefLinePaymentMethod = proxyopcode.DefLinePaymentMethod;
                                        opcode.Description = proxyopcode.Description;
                                        opcode.DisplayOPCode = proxyopcode.DisplayOPCode;
                                        opcode.DisplayOPDescription = proxyopcode.DisplayOPDescription;
                                        opcode.Engine = proxyopcode.Engine;
                                        opcode.EstimatedHours = proxyopcode.EstimatedHours;
                                        opcode.HazardMaterialCharge = proxyopcode.HazardMaterialCharge;
                                        opcode.Make = proxyopcode.Make;
                                        opcode.Mileage = proxyopcode.Mileage;
                                        opcode.Model = proxyopcode.Model;
                                        opcode.Period = proxyopcode.Period;
                                        opcode.PredefinedCauseDescription = proxyopcode.PredefinedCauseDescription;
                                        opcode.SkillLevel = proxyopcode.SkillLevel;
                                        opcode.Year = proxyopcode.Year;
                                        #endregion

                                        #region //OPCode PriceType
                                        if (proxyopcode.PriceType != null)
                                        {
                                            PriceType pricetype = new PriceType();
                                            pricetype.DiscountPrice = proxyopcode.PriceType.DiscountPrice;
                                            pricetype.DiscountRate = proxyopcode.PriceType.DiscountRate;
                                            pricetype.TotalPrice = proxyopcode.PriceType.TotalPrice;
                                            pricetype.TotalPriceIncludeTax = proxyopcode.PriceType.TotalPriceIncludeTax;
                                            pricetype.UnitPrice = proxyopcode.PriceType.UnitPrice;
                                            opcode.PriceType = pricetype;
                                        }
                                        #endregion

                                        #region //OPCode Parts
                                        if (proxyopcode.Parts != null && proxyopcode.Parts.Length > 0)
                                        {
                                            opcode.Parts = new List<Data.v2.Common.Part.Part>();
                                            foreach (_WA.Mapper.v2.OPCode.Part proxypart in proxyopcode.Parts)
                                            {
                                                #region //OPCode Part Header
                                                Data.v2.Common.Part.Part part = new Data.v2.Common.Part.Part();
                                                part.DisplayPartNumber = proxypart.DisplayPartNumber;
                                                part.PartDescription = proxypart.PartDescription;
                                                part.PartNumber = proxypart.PartNumber;
                                                part.PartType = proxypart.PartType;
                                                part.Quantity = proxypart.Quantity;
                                                part.ServiceType = proxypart.ServiceType;
                                                part.StockQuantity = proxypart.StockQuantity;
                                                part.StockStatus = proxypart.StockStatus;
                                                part.UnitOfMeasure = proxypart.UnitOfMeasure;
                                                #endregion

                                                #region //OPCode Part PriceType
                                                if (proxypart.PriceType != null)
                                                {
                                                    PriceType pricetype = new PriceType();
                                                    pricetype.DiscountPrice = proxypart.PriceType.DiscountPrice;
                                                    pricetype.DiscountRate = proxypart.PriceType.DiscountRate;
                                                    pricetype.TotalPrice = proxypart.PriceType.TotalPrice;
                                                    pricetype.TotalPriceIncludeTax = proxypart.PriceType.TotalPriceIncludeTax;
                                                    pricetype.UnitPrice = proxypart.PriceType.UnitPrice;
                                                    part.PriceType = pricetype;
                                                }
                                                #endregion

                                                opcode.Parts.Add(part);
                                            }
                                        }
                                        #endregion

                                        response.OPCodes.Add(opcode);
                                    }
                                }
                                else
                                {
                                    response.ResultMessage = GetResultMessageData(ResponseCode.NoResult, ResponseMessage.NoResult);
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            if (response.Errors != null)
                                response.Errors.Add(GetErrorData(ResponseCode.Fail, ResponseMessage.Fail));
                            else
                                response.Errors = GetErrorDataList(ResponseCode.Fail, ResponseMessage.Fail);
                        }
                        #endregion
                    }
                    break;
                case "v2.HMCIS.1C.v4":
                    {
                        #region v2.HMCIS.1C.v4 - RTR (Proxy Class Dll Name : _1C.v4)

                        #region OPCodeGet Request Set

                        //Create proxy credential
                        NetworkCredential proxycredential = new NetworkCredential(request.TransactionHeader.Username, request.TransactionHeader.Password);

                        //Create proxy web service from dms web service with credential
                        _1C.v4.OPCode.OPCode proxyws = new _1C.v4.OPCode.OPCode(request.TransactionHeader.DMSServerUrl);
                        proxyws.Credentials = proxycredential;

                        //Create proxy request with opcodeget and transaction
                        _1C.v4.OPCode.OPCodeGetRequest proxyrequest = new _1C.v4.OPCode.OPCodeGetRequest();

                        //Create proxy transaction
                        _1C.v4.OPCode.TransactionHeader proxytransactionheader = new _1C.v4.OPCode.TransactionHeader();
                        if (request.TransactionHeader != null)
                        {
                            #region//TransactionHeader Set
                            proxytransactionheader.CountryID = request.TransactionHeader.CountryID;
                            proxytransactionheader.DealerID = request.TransactionHeader.DealerID;
                            proxytransactionheader.DistributorID = request.TransactionHeader.DistributorID;
                            proxytransactionheader.DMSCode = request.TransactionHeader.DMSCode;
                            proxytransactionheader.DMSServerUrl = request.TransactionHeader.DMSServerUrl;
                            proxytransactionheader.DMSVersion = request.TransactionHeader.DMSVersion;
                            proxytransactionheader.DocumentVersion = request.TransactionHeader.DocumentVersion;
                            proxytransactionheader.GroupID = request.TransactionHeader.GroupID;
                            proxytransactionheader.IneterfaceID = request.TransactionHeader.IneterfaceID;
                            proxytransactionheader.Password = request.TransactionHeader.Password;
                            proxytransactionheader.PollingToken = request.TransactionHeader.PollingToken;
                            proxytransactionheader.RequestPollingToken = request.TransactionHeader.RequestPollingToken;
                            proxytransactionheader.RequestType = request.TransactionHeader.RequestType;
                            proxytransactionheader.TransactionId = request.TransactionHeader.TransactionId;
                            proxytransactionheader.TransactionDateTimeLocal = request.TransactionHeader.TransactionDateTimeLocal;
                            proxytransactionheader.TransactionDateTimeUTC = request.TransactionHeader.TransactionDateTimeUTC;
                            proxytransactionheader.TransactionType = request.TransactionHeader.TransactionType;
                            proxytransactionheader.Username = request.TransactionHeader.Username;
                            proxytransactionheader.VenderTrackingCode = request.TransactionHeader.VenderTrackingCode;
                            proxyrequest.TransactionHeader = proxytransactionheader;
                            #endregion
                        }

                        //Create proxy opcodeget
                        _1C.v4.OPCode.OPCodeGet proxyopcodeget = new _1C.v4.OPCode.OPCodeGet();
                        if (request.OPCodeGet != null)
                        {
                            #region//OPCodeGet Set
                            proxyopcodeget.Category = request.OPCodeGet.Category;
                            proxyopcodeget.Code = request.OPCodeGet.Code;
                            proxyopcodeget.Description = request.OPCodeGet.Description;
                            proxyopcodeget.Engine = request.OPCodeGet.Engine;
                            proxyopcodeget.Make = request.OPCodeGet.Make;
                            proxyopcodeget.Mileage = request.OPCodeGet.Mileage;
                            proxyopcodeget.Model = request.OPCodeGet.Model;
                            proxyopcodeget.Year = request.OPCodeGet.Year;
                            proxyrequest.OPCodeGet = proxyopcodeget;
                            #endregion
                        }
                        #endregion

                        //Run proxy web method with proxy request
                        _1C.v4.OPCode.OPCodeGetResponse proxyresponse = proxyws.OPCodeGet(proxyrequest);

                        //Mapping with Standard Interface Specification Object
                        if (proxyresponse != null)
                        {
                            //ResultMessage Set
                            if (proxyresponse.ResultMessage != null)
                            {
                                response.ResultMessage = GetResultMessageData(proxyresponse.ResultMessage.Code, proxyresponse.ResultMessage.Message);
                            }

                            if (proxyresponse.Errors != null)
                            {
                                //Error List Set
                                foreach (_1C.v4.OPCode.Error proxyerror in proxyresponse.Errors)
                                {
                                    if (response.Errors != null)
                                        response.Errors.Add(GetErrorData(proxyerror.Code, proxyerror.Message));
                                    else
                                        response.Errors = GetErrorDataList(proxyerror.Code, proxyerror.Message);
                                }
                            }
                            else
                            {
                                #region //OPCodeGetResponse Set

                                if (proxyresponse.TransactionHeader != null)
                                {
                                    #region//TransactionHeader Set
                                    TransactionHeader transactionheader = new TransactionHeader();
                                    transactionheader.CountryID = proxyresponse.TransactionHeader.CountryID;
                                    transactionheader.DealerID = proxyresponse.TransactionHeader.DealerID;
                                    transactionheader.DistributorID = proxyresponse.TransactionHeader.DistributorID;
                                    transactionheader.DMSCode = proxyresponse.TransactionHeader.DMSCode;
                                    transactionheader.DMSServerUrl = proxyresponse.TransactionHeader.DMSServerUrl;
                                    transactionheader.DMSVersion = proxyresponse.TransactionHeader.DMSVersion;
                                    transactionheader.DocumentVersion = proxyresponse.TransactionHeader.DocumentVersion;
                                    transactionheader.GroupID = proxyresponse.TransactionHeader.GroupID;
                                    transactionheader.IneterfaceID = proxyresponse.TransactionHeader.IneterfaceID;
                                    transactionheader.Password = proxyresponse.TransactionHeader.Password;
                                    transactionheader.PollingToken = proxyresponse.TransactionHeader.PollingToken;
                                    transactionheader.RequestPollingToken = proxyresponse.TransactionHeader.RequestPollingToken;
                                    transactionheader.RequestType = proxyresponse.TransactionHeader.RequestType;
                                    transactionheader.TransactionId = proxyresponse.TransactionHeader.TransactionId;
                                    transactionheader.TransactionDateTimeLocal = proxyresponse.TransactionHeader.TransactionDateTimeLocal;
                                    transactionheader.TransactionDateTimeUTC = proxyresponse.TransactionHeader.TransactionDateTimeUTC;
                                    transactionheader.TransactionType = proxyresponse.TransactionHeader.TransactionType;
                                    transactionheader.Username = proxyresponse.TransactionHeader.Username;
                                    transactionheader.VenderTrackingCode = proxyresponse.TransactionHeader.VenderTrackingCode;
                                    response.TransactionHeader = transactionheader;
                                    #endregion
                                }

                                if (proxyresponse.OPCodes != null && proxyresponse.OPCodes.Length > 0)
                                {
                                    response.OPCodes = new List<Data.v2.Common.OPCode.OPCode>();
                                    foreach (_1C.v4.OPCode.OPCode1 proxyopcode in proxyresponse.OPCodes)
                                    {
                                        #region //OPCode Header
                                        Data.v2.Common.OPCode.OPCode opcode = new Data.v2.Common.OPCode.OPCode();
                                        opcode.Code = proxyopcode.Code;
                                        opcode.CorrectionLOP = proxyopcode.CorrectionLOP;
                                        opcode.CPSIND = proxyopcode.CPSIND;
                                        opcode.DefLinePaymentMethod = proxyopcode.DefLinePaymentMethod;
                                        opcode.Description = proxyopcode.Description;
                                        opcode.DisplayOPCode = proxyopcode.DisplayOPCode;
                                        opcode.DisplayOPDescription = proxyopcode.DisplayOPDescription;
                                        opcode.Engine = proxyopcode.Engine;
                                        opcode.EstimatedHours = proxyopcode.EstimatedHours;
                                        opcode.HazardMaterialCharge = proxyopcode.HazardMaterialCharge;
                                        opcode.Make = proxyopcode.Make;
                                        opcode.Mileage = proxyopcode.Mileage;
                                        opcode.Model = proxyopcode.Model;
                                        opcode.Period = proxyopcode.Period;
                                        opcode.PredefinedCauseDescription = proxyopcode.PredefinedCauseDescription;
                                        opcode.SkillLevel = proxyopcode.SkillLevel;
                                        opcode.Year = proxyopcode.Year;
                                        #endregion

                                        #region //OPCode PriceType
                                        if (proxyopcode.PriceType != null)
                                        {
                                            PriceType pricetype = new PriceType();
                                            pricetype.DiscountPrice = proxyopcode.PriceType.DiscountPrice;
                                            pricetype.DiscountRate = proxyopcode.PriceType.DiscountRate;
                                            pricetype.TotalPrice = proxyopcode.PriceType.TotalPrice;
                                            pricetype.TotalPriceIncludeTax = proxyopcode.PriceType.TotalPriceIncludeTax;
                                            pricetype.UnitPrice = proxyopcode.PriceType.UnitPrice;
                                            opcode.PriceType = pricetype;
                                        }
                                        #endregion

                                        #region //OPCode Parts
                                        if (proxyopcode.Parts != null && proxyopcode.Parts.Length > 0)
                                        {
                                            opcode.Parts = new List<Data.v2.Common.Part.Part>();
                                            foreach (_1C.v4.OPCode.Part proxypart in proxyopcode.Parts)
                                            {
                                                #region //OPCode Part Header
                                                Data.v2.Common.Part.Part part = new Data.v2.Common.Part.Part();
                                                part.DisplayPartNumber = proxypart.DisplayPartNumber;
                                                part.PartDescription = proxypart.PartDescription;
                                                part.PartNumber = proxypart.PartNumber;
                                                part.PartType = proxypart.PartType;
                                                part.Quantity = proxypart.Quantity;
                                                part.ServiceType = proxypart.ServiceType;
                                                part.StockQuantity = proxypart.StockQuantity;
                                                part.StockStatus = proxypart.StockStatus;
                                                part.UnitOfMeasure = proxypart.UnitOfMeasure;
                                                #endregion

                                                #region //OPCode Part PriceType
                                                if (proxypart.PriceType != null)
                                                {
                                                    PriceType pricetype = new PriceType();
                                                    pricetype.DiscountPrice = proxypart.PriceType.DiscountPrice;
                                                    pricetype.DiscountRate = proxypart.PriceType.DiscountRate;
                                                    pricetype.TotalPrice = proxypart.PriceType.TotalPrice;
                                                    pricetype.TotalPriceIncludeTax = proxypart.PriceType.TotalPriceIncludeTax;
                                                    pricetype.UnitPrice = proxypart.PriceType.UnitPrice;
                                                    part.PriceType = pricetype;
                                                }
                                                #endregion

                                                opcode.Parts.Add(part);
                                            }
                                        }
                                        #endregion

                                        response.OPCodes.Add(opcode);
                                    }
                                }
                                else
                                {
                                    response.ResultMessage = GetResultMessageData(ResponseCode.NoResult, ResponseMessage.NoResult);
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            if (response.Errors != null)
                                response.Errors.Add(GetErrorData(ResponseCode.Fail, ResponseMessage.Fail));
                            else
                                response.Errors = GetErrorDataList(ResponseCode.Fail, ResponseMessage.Fail);
                        }
                        #endregion
                    }
                    break;
                default: response.Errors = new List<Error>() { new Error() { Code = ResponseCode.NoMatchedProxy, Message = ResponseMessage.NoMatchedProxy } };
                    break;
            }

            return response;
        }
Esempio n. 4
0
        public OPCodeGetResponse OPCodeGet(OPCodeGetRequest request)
        {
            OPCodeGetResponse response = new OPCodeGetResponse();

            if (base.RunningMode.Equals(Base.RunningMode.Mapper))
            {
                #region For Mapper Process
                WA.Standard.IF.Proxy.v2.Common.OPCode_Proxy proxy = new Proxy.v2.Common.OPCode_Proxy();
                response = proxy.OPCodeGet(request);
                #endregion
            }
            else if (base.RunningMode.Equals(Base.RunningMode.XMLDMS))
            {
                response.TransactionHeader = request.TransactionHeader;

                #region For XML Process
                List<WA.Standard.IF.Data.v2.Common.OPCode.OPCode> OPCodes = Util.DataHelper.GetListByElementName<WA.Standard.IF.Data.v2.Common.OPCode.OPCode>(System.Web.HttpContext.Current.Server.MapPath("/v2/Repository/OPCodes.xml"), "OPCode");

                if (OPCodes != null && OPCodes.Count > 0)
                {
                    List<WA.Standard.IF.Data.v2.Common.OPCode.OPCode> resultlist = OPCodes
                        .Where(item =>
                        (string.IsNullOrEmpty(request.OPCodeGet.Category) || true)
                        && (string.IsNullOrEmpty(request.OPCodeGet.Code) || item.Code.Contains(request.OPCodeGet.Code))
                        && (string.IsNullOrEmpty(request.OPCodeGet.Description) || item.Description.Contains(request.OPCodeGet.Description))
                        && (string.IsNullOrEmpty(request.OPCodeGet.Engine) || request.OPCodeGet.Engine == item.Engine)
                        && (string.IsNullOrEmpty(request.OPCodeGet.Make) || request.OPCodeGet.Make == item.Make)
                        && (string.IsNullOrEmpty(request.OPCodeGet.Mileage) || request.OPCodeGet.Mileage == item.Mileage)
                        && (string.IsNullOrEmpty(request.OPCodeGet.Model) || request.OPCodeGet.Model == item.Model)
                        && (string.IsNullOrEmpty(request.OPCodeGet.Year) || request.OPCodeGet.Year == item.Year)
                        ).ToList<WA.Standard.IF.Data.v2.Common.OPCode.OPCode>();

                    response.OPCodes = resultlist;

                    if (resultlist.Count > 0)
                        response.ResultMessage = GetResultMessageData(ResponseCode.Success, ResponseMessage.Success);
                    else
                        response.ResultMessage = GetResultMessageData(ResponseCode.NoResult, ResponseMessage.NoResult);
                }
                else
                {
                    response.ResultMessage = GetResultMessageData(ResponseCode.NoResult, ResponseMessage.NoResult);
                }
                #endregion
            }
            else if (base.RunningMode.Equals(Base.RunningMode.DBDMS))
            {
                #region For DB Process

                /*
                DataSet resultDS = new DataSet();
                using (OPCode_Dac opCode_Dac = new OPCode_Dac())
                {
                    resultDS = opCode_Dac.SelectOPCode(request.TransactionHeader.CountryID
                                                        , request.TransactionHeader.DistributorID
                                                        , request.TransactionHeader.GroupID
                                                        , request.TransactionHeader.DealerID
                                                        , request.TransactionHeader.Language
                                                        , request.OPCodeGet
                        );

                }

                //0. OPCode Data
                //1. Parts Data - Not Used

                if (resultDS.Tables != null && resultDS.Tables.Count > 0)
                {
                    #region OPCode
                    List<WA.Standard.IF.Data.v2.Common.OPCode.OPCode> OPCodes = null;
                    OPCodes = resultDS.Tables[0].AsEnumerable()
                        .Select(row =>
                    new WA.Standard.IF.Data.v2.Common.OPCode.OPCode
                    {
                        DMSOPCodeNo = Util.DataHelper.ConvertObjectToString(row["DMSOPCodeNo"]),
                        Code = Util.DataHelper.ConvertObjectToString(row["Code"]),
                        CorrectionLOP = Util.DataHelper.ConvertObjectToString(row["CorrectionLOP"]),
                        CPSIND = Util.DataHelper.ConvertObjectToString(row["CPSIND"]),
                        DefLinePaymentMethod = Util.DataHelper.ConvertObjectToString(row["DefLinePaymentMethod"]),
                        Description = Util.DataHelper.ConvertObjectToString(row["Description"]),
                        DisplayOPCode = Util.DataHelper.ConvertObjectToString(row["DisplayOPCode"]),
                        DisplayOPDescription = Util.DataHelper.ConvertObjectToString(row["DisplayOPDescription"]),
                        Engine = Util.DataHelper.ConvertObjectToString(row["Engine"]),
                        EstimatedHours = Util.DataHelper.ConvertObjectToDouble(row["EstimatedHours"]),
                        HazardMaterialCharge = Util.DataHelper.ConvertObjectToDouble(row["HazardMaterialCharge"]),
                        Make = Util.DataHelper.ConvertObjectToString(row["Make"]),
                        Mileage = Util.DataHelper.ConvertObjectToString(row["Mileage"]),
                        Model = Util.DataHelper.ConvertObjectToString(row["Model"]),
                        Period = Util.DataHelper.ConvertObjectToString(row["Period"]),
                        PredefinedCauseDescription = Util.DataHelper.ConvertObjectToString(row["PredefinedCauseDescription"]),
                        SkillLevel = Util.DataHelper.ConvertObjectToString(row["SkillLevel"]),
                        Year = Util.DataHelper.ConvertObjectToString(row["Year"]),
                        PriceType = new PriceType()
                        {
                            DiscountPrice = Util.DataHelper.ConvertObjectToDouble(row["DiscountPrice"]),
                            DiscountRate = Util.DataHelper.ConvertObjectToDouble(row["DiscountRate"]),
                            TotalPrice = Util.DataHelper.ConvertObjectToDouble(row["TotalPrice"]),
                            TotalPriceIncludeTax = Util.DataHelper.ConvertObjectToDouble(row["TotalPriceIncludeTax"]),
                            UnitPrice = Util.DataHelper.ConvertObjectToDouble(row["UnitPrice"])
                        },
                        Parts = new List<Data.v2.Common.Part.Part>(),
                    }).ToList();

                    if (OPCodes != null && OPCodes.Count > 0 && resultDS.Tables.Count > 1 && resultDS.Tables[1].Rows.Count > 0)
                    {
                        foreach (WA.Standard.IF.Data.v2.Common.OPCode.OPCode opcode in OPCodes)
                        {
                            #region Parts
                            List<WA.Standard.IF.Data.v2.Common.Part.Part> Parts = null;
                            Parts = resultDS.Tables[1].AsEnumerable()
                                .Where(row => Util.DataHelper.ConvertObjectToString(row["DMSOPCodeNo"]) == opcode.DMSOPCodeNo)
                                .Select(row =>
                            new WA.Standard.IF.Data.v2.Common.Part.Part
                            {
                                DisplayPartNumber = Util.DataHelper.ConvertObjectToString(row["DisplayPartNumber"]),
                                DisplayRemarks = Util.DataHelper.ConvertObjectToString(row["DisplayRemarks"]),
                                Manufacturer = Util.DataHelper.ConvertObjectToString(row["Manufacturer"]),
                                PartDescription = Util.DataHelper.ConvertObjectToString(row["PartDescription"]),
                                PartNumber = Util.DataHelper.ConvertObjectToString(row["PartNumber"]),
                                PartStatus = Util.DataHelper.ConvertObjectToString(row["PartStatus"]),
                                PartType = Util.DataHelper.ConvertObjectToString(row["PartType"]),
                                Quantity = Util.DataHelper.ConvertObjectToDouble(row["Quantity"]),
                                QuantityOnHand = Util.DataHelper.ConvertObjectToDouble(row["QuantityOnHand"]),
                                Remarks = Util.DataHelper.ConvertObjectToString(row["Remarks"]),
                                ServiceType = Util.DataHelper.ConvertObjectToString(row["ServiceType"]),
                                StockQuantity = Util.DataHelper.ConvertObjectToDouble(row["StockQuantity"]),
                                StockStatus = Util.DataHelper.ConvertObjectToString(row["StockStatus"]),
                                UnitOfMeasure = Util.DataHelper.ConvertObjectToString(row["UnitOfMeasure"]),
                                PriceType = new PriceType()
                                {
                                    DiscountPrice = Util.DataHelper.ConvertObjectToDouble(row["DiscountPrice"]),
                                    DiscountRate = Util.DataHelper.ConvertObjectToDouble(row["DiscountRate"]),
                                    TotalPrice = Util.DataHelper.ConvertObjectToDouble(row["TotalPrice"]),
                                    TotalPriceIncludeTax = Util.DataHelper.ConvertObjectToDouble(row["TotalPriceIncludeTax"]),
                                    UnitPrice = Util.DataHelper.ConvertObjectToDouble(row["UnitPrice"])
                                },
                            }).ToList();
                            if (Parts != null && Parts.Count > 0)
                                opcode.Parts = Parts;
                            #endregion
                        }

                        response.ResultMessage = GetResultMessageData(PredefinedCode._SuccessDone, PredefinedMessage._SuccessDone);
                        response.OPCodes = OPCodes;
                    }
                    else
                    {
                        response.ResultMessage = GetResultMessageData(PredefinedCode._SuccessNoResult, PredefinedMessage._SuccessNoResult);
                    }
                    #endregion
                }
                else
                {
                    response.ResultMessage = GetResultMessageData(PredefinedCode._SuccessNoResult, PredefinedMessage._SuccessNoResult);
                }
                 */
                #endregion
            }

            return response;
        }