Exemple #1
0
        public void AddnewRecordInVehicleStatus(Int32 iVehicleId, Int32 iShopId, ImportData objImportData)
        {
            UserBL objUserBL = null;
            String strShopId = String.Empty;
            //Get Vehicle Info object from current vehicle ID
            VehicleInfoBL objVehicleInfoBL = VehicleInfoBL.getDataId(iVehicleId);

            if (objVehicleInfoBL != null)
            {
                //Create UserBL object from user ID used in Vehicle Info table
                objUserBL = UserBL.getByActivityId(Convert.ToInt32(objVehicleInfoBL.iUserId));
                strShopId = Convert.ToString(iShopId);
            }

            if (objUserBL != null && objVehicleInfoBL != null && !String.IsNullOrEmpty(strShopId))
            {
                SaveVehicleStatus(objVehicleInfoBL, objImportData, objUserBL, strShopId);
                UserVehicleStatusBL objUserVehicleStatusBL = UserVehicleStatusBL.getDataByVehicleId(iVehicleId);
                if (objUserVehicleStatusBL != null)
                {
                    MarketingUsers objMarUser = MarketingUsers.getDataByShopUserAndVehicleId(iShopId, Convert.ToInt32(objVehicleInfoBL.iUserId), iVehicleId);
                    objMarUser.bisShowInProcess = true;
                    objMarUser.Save();
                }
            }
            else
            {
                return;
            }
        }
Exemple #2
0
        private Boolean updateVehicleStatus(Int32 iVehicleId, Int32 iShopId, ImportData objImportData)
        {
            try
            {
                UserVehicleStatusBL objCustomerVehicleStatus = UserVehicleStatusBL.getDataByVehicleId(iVehicleId);
                if (objCustomerVehicleStatus != null)
                {
                    DateTime dtOut;
                    objCustomerVehicleStatus.dtDateIn  = DateTime.TryParse(objImportData.Scheduled_In_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtDateOut = DateTime.TryParse(objImportData.Target_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtActual_Delivery_Date = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtFile_Import_Date     = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtFile_Import_Time     = DateTime.TryParse(objImportData.File_Import_Time, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtRepair_Start_Date    = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtDeliveryDate         = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.iETA_Hours             = Convert.ToInt32(objImportData.ETA_Hours);
                    objCustomerVehicleStatus.iRO_Hours      = Convert.ToInt32(objImportData.RO_Hours);
                    objCustomerVehicleStatus.strFile_Status = objImportData.File_Status;
                    objCustomerVehicleStatus.Save();


                    //Set Show InProcess true for current vehicle
                    //MarketingUsers objMarUser = MarketingUsers.getDataByShopUserAndVehicleId(iShopId, Convert.ToInt32(objCustomerVehicleStatus.iUserId), iVehicleId);
                    //objMarUser.bisShowInProcess = true;
                    //return objMarUser.Save();
                }
                else
                {
                    //SaveVehicleStatus(VehicleInfoBL objVehicleInfo, ImportData objImportData, UserBL objUser, String strShopId)
                    //Insert new record in UserVehicleStatus table
                    AddnewRecordInVehicleStatus(iVehicleId, iShopId, objImportData);
                }
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, SummitShopApp.Utility.Constants.ExceptionPolicy);
            }
            return(false);
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                String strPhoneId = String.Empty;
                String strImage   = String.Empty;
                String strNewApp  = String.Empty;

                if (!String.IsNullOrEmpty(Request.QueryString["ShopID"]))
                {
                    if (!Int32.TryParse(Security.DecodeNumbers(Request.QueryString["ShopID"]), out iShopID))
                    {
                        return;
                    }
                }
                //else
                //{
                //    Int32.TryParse(strNewApp, out iShopID);
                //}


                if (Request.QueryString["User_Id"] != null)
                {
                    strPhoneId = Request.QueryString["User_Id"];
                    strNewApp  = Request.QueryString["N"];
                }
                else if (Request.Form["User_Id"] != null)
                {
                    strPhoneId = Request.Form["User_Id"];
                    strNewApp  = Request.Form["N"];
                }

                //Check phone no is not empty/null
                if (!String.IsNullOrEmpty(strPhoneId))
                {
                    List <MyCustomerBL> lstMyCustomer = null;
                    UserBL objUser = null;
                    if (iShopID != 0)
                    {
                        MyCustomerBL objMyCustomer = null;
                        lstMyCustomer = MyCustomerBL.getDataByShopIDandMobileList(iShopID, strPhoneId);

                        if (lstMyCustomer != null && lstMyCustomer.Count > 0)
                        {
                            objMyCustomer = lstMyCustomer.Find(t => t.strStatusOfVehicle.ToLower().Trim() != Constants.VEHICLE_STATUS_DELIVERED.ToLower().Trim());
                        }

                        if (objMyCustomer != null)
                        {
                            if (!String.IsNullOrEmpty(objMyCustomer.strStatusOfVehicle))
                            {
                                //If status is delivered then dont show details for this customer
                                if (objMyCustomer.strStatusOfVehicle.ToLower().Trim() == Constants.VEHICLE_STATUS_DELIVERED.ToLower().Trim())
                                {
                                    return;
                                }
                            }



                            objUser = UserBL.getByActivityId(objMyCustomer.iUserId.Value);
                            //remove diffrent name customers, there should be only same name customers
                            lstMyCustomer.RemoveAll(p1 => p1.strUserName != objMyCustomer.strUserName);
                        }

                        ////Find User using phone no & shopID
                        //MyCustomerBL objMyCustomer = MyCustomerBL.getDataByShopIdNPhone(iShopID, strPhoneId);
                        //if (objMyCustomer != null)
                        //{
                        //    objUser = UserBL.getByActivityId(objMyCustomer.iUserId.Value);

                        //}
                    }
                    else
                    {
                        string[] strPhones = strPhoneId.Split('_');

                        //find user using phoneID for private label
                        if (strPhones.Length == 3)
                        {
                            objUser = UserBL.getDataByPhoneId(strPhoneId);
                        }
                        else
                        {
                            objUser = UserBL.GetDataByPhoneNumber(strPhones[0]);
                        }
                    }
                    if (objUser != null)
                    {
                        List <VehicleInfoBL> lstVehicleInfo = null;
                        if (lstMyCustomer != null)
                        {
                            lstVehicleInfo = new List <VehicleInfoBL>();
                            foreach (MyCustomerBL objMyCustomerBL in lstMyCustomer)
                            {
                                //get Customer's Vehicle Details
                                lstVehicleInfo.AddRange(VehicleInfoBL.getDataByUserId(objMyCustomerBL.iUserId.Value));
                            }
                        }
                        else
                        {
                            //if user found get vehicle info
                            lstVehicleInfo = VehicleInfoBL.getDataByUserId(objUser.ID);
                        }
                        if (lstVehicleInfo != null)
                        {
                            foreach (var objVehicleInfo in lstVehicleInfo)
                            {
                                //get count of vehicle media links newly uploaded
                                iCount += VehicleMediaLinkBL.getNewLinkCountByVehicleID(objVehicleInfo.ID);
                                //get Vehicle status Changed
                                UserVehicleStatusBL objUserVehicleStatusBL = UserVehicleStatusBL.getDataByVehicleId(objVehicleInfo.ID);
                                if (objUserVehicleStatusBL != null && objUserVehicleStatusBL.bIsRead.HasValue && objUserVehicleStatusBL.bIsRead.Value == 1)
                                {
                                    strVehicleStatus = "true";
                                }
                            }
                            ////Find current vehicle info
                            //VehicleInfoBL objVehicleInfo = lstVehicleInfo.Find(p => p.bIsUsing == true || p.bIsUsing == null);
                            //if (objVehicleInfo != null)
                            //{
                            //    //get count of vehicle media links newly uploaded
                            //    iCount = VehicleMediaLinkBL.getNewLinkCountByVehicleID(objVehicleInfo.ID);
                            //    //get Vehicle status Changed
                            //    UserVehicleStatusBL objUserVehicleStatusBL = UserVehicleStatusBL.getDataByVehicleId(objVehicleInfo.ID);
                            //    if (objUserVehicleStatusBL != null && objUserVehicleStatusBL.bIsRead.HasValue && objUserVehicleStatusBL.bIsRead.Value == 1)
                            //        strVehicleStatus = "true";
                            //}
                        }
                    }
                    //for sending info to html5 app using xml
                    XmlDocument  xmlDoc = new XmlDocument();
                    MemoryStream stream = new MemoryStream();
                    //XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.ASCII);
                    XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("VehicleMediaCount");
                    //count for newly uploaded vehiclemedia links
                    xmlWriter.WriteElementString("Count", String.IsNullOrEmpty(iCount.ToString()) ? "" : iCount.ToString());
                    //check vehicleStatus
                    xmlWriter.WriteElementString("VehicleStatus", String.IsNullOrEmpty(strVehicleStatus) ? "" : strVehicleStatus);


                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();
                    xmlWriter.Flush();
                    byte[] byteArray = stream.ToArray();
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "filename=MyExportedFile.xml");
                    HttpContext.Current.Response.AppendHeader("Content-Length", byteArray.Length.ToString());
                    HttpContext.Current.Response.ContentType = "text/xml";
                    HttpContext.Current.Response.BinaryWrite(byteArray);
                }
            }
            catch (Exception ex)
            {
            }
        }