コード例 #1
0
        public ActionResult Index(QRCModel ObjQRCModel)
        {
            DARModel            objDAR;
            long                Totalrecords           = 0;
            eTracLoginModel     ObjLoginModel          = new eTracLoginModel();
            LocationMasterModel objLocationMasterModel = null;

            try
            {
                //if (ModelState.IsValid)
                if (true)
                {
                    #region login model
                    ////
                    if (Session["eTrac"] != null)
                    {
                        ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);

                        // ObjQRCModel.UserModel.ProjectID = (ObjLoginModel != null && ObjLoginModel.LocationID > 0) ? (ObjLoginModel.LocationID) : 0;
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Login"));
                    }
                    ///
                    #endregion login model

                    long          _qRCId = 0;
                    Result        _fnResult, result;
                    PrintQRCModel ObjPrintQRCModel;
                    CommonHelper  ObjCommonHelper = new CommonHelper();
                    string        QRCImageName    = string.Empty;
                    //string msg;
                    if (Session["ImageName"] != null)
                    {
                        ObjQRCModel.UserModel.myProfileImage = Convert.ToString(Session["ImageName"]);
                    }

                    if (ObjQRCModel.WarrantyDocument != null)
                    {
                        ObjQRCModel.WarrantyDoc = DateTime.Now.Ticks + "_" + ObjQRCModel.WarrantyDocument.FileName.Replace(" ", "");
                    }
                    if (ObjQRCModel.LOCPicture != null)
                    {
                        ObjQRCModel.LocationPicture = DateTime.Now.Ticks + "_" + ObjQRCModel.LOCPicture.FileName.Replace(" ", "");
                    }
                    if (ObjQRCModel.AssetPictureUrl != null)
                    {
                        ObjQRCModel.AssetPicture = DateTime.Now.Ticks + "_" + ObjQRCModel.AssetPictureUrl.FileName.Replace(" ", "");
                    }

                    ObjQRCModel.CreatedBy  = ObjLoginModel.UserId;
                    ObjQRCModel.LocationId = ObjLoginModel.LocationID;

                    objDAR            = new DARModel();
                    objDAR.LocationId = ObjLoginModel.LocationID;
                    objDAR.UserId     = ObjLoginModel.UserId;
                    objDAR.CreatedBy  = ObjLoginModel.UserId;
                    objDAR.CreatedOn  = DateTime.UtcNow;

                    //Added by Bhushan on 26/Oct/2016 for client has changed request for If QRC is vehicle then directly set vehicle type is Motor Vehicle and for Shuttle Bus  set vehicle type is Shuttle Bus
                    if (ObjQRCModel.QRCTYPE == Convert.ToInt64(QrcType.Vehicle))
                    {
                        ObjQRCModel.VehicleType = Convert.ToInt64(VEHICLETYPE.MotorVehicle);
                    }
                    if (ObjQRCModel.QRCTYPE == Convert.ToInt64(QrcType.ShuttleBus))
                    {
                        ObjQRCModel.VehicleType = Convert.ToInt64(VEHICLETYPE.ShuttleBus);
                    }

                    if (_IQRCSetup.ProcessQRCSetup(ObjQRCModel, out _qRCId, out _fnResult, out ObjPrintQRCModel))
                    {
                        path = Server.MapPath(path);

                        if (ObjQRCModel.WarrantyDocument != null)
                        {
                            ObjCommonHelper.UploadImage(ObjQRCModel.WarrantyDocument, path, ObjQRCModel.WarrantyDoc);
                        }
                        if (ObjQRCModel.LOCPicture != null)
                        {
                            ObjCommonHelper.UploadImage(ObjQRCModel.LOCPicture, path, ObjQRCModel.LocationPicture);
                        }
                        if (ObjQRCModel.AssetPictureUrl != null)
                        {
                            ObjCommonHelper.UploadImage(ObjQRCModel.AssetPictureUrl, path, ObjQRCModel.AssetPicture);
                        }

                        if (_fnResult == Result.Completed)
                        {
                            // Code for to get path of root directory and attach path of directory to store image

                            string RootDirectory = ConfigurationManager.AppSettings["QRCImage"];
                            RootDirectory = Server.MapPath(RootDirectory);
                            if (ObjQRCModel.QRCImageBase64 != null)
                            {
                                ObjQRCModel.QRCImageBase64 = ObjQRCModel.QRCImageBase64.Split(',')[1];
                                ObjCommonHelper.UploadQRCImage(ObjQRCModel.QRCImageBase64, RootDirectory, ObjQRCModel.QRCImage);
                            }

                            objDAR.ActivityDetails = DarMessage.SaveQRC(ObjPrintQRCModel.QRCName, ObjLoginModel.Location);
                            objDAR.TaskType        = (long)TaskTypeCategory.QRCCreation;

                            ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                            ModelState.Clear();
                            ObjQRCModel = QRCInIt();
                        }
                        else if (_fnResult == Result.UpdatedSuccessfully)
                        {
                            objDAR.ActivityDetails = DarMessage.UpdateQRC(ObjPrintQRCModel.QRCName, ObjLoginModel.Location);
                            objDAR.TaskType        = (long)TaskTypeCategory.QRCUpdate;

                            ViewBag.Message           = CommonMessage.UpdateSuccessMessage();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                            ModelState.Clear();
                            ObjQRCModel = QRCInIt();
                        }
                        else if (_fnResult == Result.Failed)
                        {
                            ViewBag.Message           = CommonMessage.FailureMessage();
                            ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                            // store the failure message in tempdata to display in view.
                        }

                        #region Save DAR
                        result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                    else
                    {
                        ViewBag.Message           = CommonMessage.DuplicateRecordMessage();
                        ViewBag.AlertMessageClass = ObjAlertMessageClass.Info;
                        // store the failure message in tempdata to display in view.
                    }
                    //ViewBag.EncryptQRC = Cryptography.GetEncryptedData(QRCDetail.QRCId.ToString(), true);

                    //ViewBag.EncryptQRC = Cryptography.GetEncryptedData(_qRCId.ToString(), true);

                    ViewBag.QRCName     = ObjQRCModel.QRCName;
                    ViewBag.SpecialNote = ObjQRCModel.SpecialNotes;

                    //ViewBag.QRCSize = QRCDetail.DefaultSize;

                    /*
                     *                  ObjPrintQRCModel = new PrintQRCModel();
                     *
                     *
                     *                  /// pull details from ObjQRCModel and plug into ObjPrintQRCModel
                     *                  ObjPrintQRCModel.QRCId = ObjQRCModel.QRCId;
                     *
                     *                  ObjPrintQRCModel.QRCName = ObjQRCModel.QRCName;
                     *                  ObjPrintQRCModel.SpecialNotes = ObjQRCModel.SpecialNotes;
                     *                  ObjPrintQRCModel.QRCTYPE = ObjQRCModel.QRCTYPECaption;
                     *                  ObjPrintQRCModel.VehicleType = ObjQRCModel.VehicleTypeCaption;
                     *                  ObjPrintQRCModel.MotorType = ObjQRCModel.MotorTypeCaption;
                     */


                    /// pull details from ObjQRCModel and plug into ObjPrintQRCModel End

                    ObjPrintQRCModel.QRCSize    = _ICommonMethod.GetGlobalCodeData("QRCSIZE");
                    ObjPrintQRCModel.EncryptQRC = Cryptography.GetEncryptedData(ObjPrintQRCModel.QRCId.ToString(), true);

                    ObjPrintQRCModel.CompanyLogo  = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.LocationLogo)) ? (ObjLoginModel.LocationLogo) : "/";
                    ObjPrintQRCModel.CompanyImage = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.LocationImage)) ? (ObjLoginModel.LocationImage) : "/";
                    ObjPrintQRCModel.CompanyName  = (ObjLoginModel != null && !string.IsNullOrEmpty(ObjLoginModel.Location)) ? (ObjLoginModel.Location) : "/";

                    objLocationMasterModel    = _IGlobalAdmin.GetLocationById(ObjPrintQRCModel.LocationId);
                    ObjPrintQRCModel.Location = objLocationMasterModel.LocationName;

                    //ViewBag.EncryptQRC = ObjPrintQRCModel.EncryptQRC;
                    ViewBag.EncryptQRC     = ObjPrintQRCModel.QRCIDCode;
                    ViewBag.LastEncryptQRC = ObjPrintQRCModel.QRCIDCode;// + ',' + ObjPrintQRCModel.QRCTYPEID;//This field added by Bhushan Dod  //After comma we don't need type of QRC.We need to comment .
                    ViewBag.QRCSize        = ObjPrintQRCModel.QRCSize;

                    //PrintQRCModel ObjPrintQRCModel;
                    ViewBag.QRCModel = ObjPrintQRCModel;
                }
                else
                {
                    var    errors   = ModelState.Values.SelectMany(v => v.Errors);
                    string _message = "";
                    foreach (var items in errors)
                    {
                        _message = _message + items.ErrorMessage;
                    }
                    ViewBag.Message = _message;
                    ObjQRCModel     = _IQRCSetup.GetGlobalCodeForCategories();
                }
            }
            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "Exception For File Upload", path.ToString(), null);
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                ObjQRCModel       = _IQRCSetup.GetGlobalCodeForCategories();
                ViewBag.Country   = _ICommonMethod.GetAllcountries();
                ViewBag.PurchType = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE");
                return(View(ObjQRCModel));
            }
            ObjQRCModel     = _IQRCSetup.GetGlobalCodeForCategories();
            ViewBag.Country = _ICommonMethod.GetAllcountries();
            // ViewBag.PurchType = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE");
            ViewBag.PurchType   = _ICommonMethod.GetGlobalCodeDataList("PURCHASETYPE");
            ViewBag.RefreshMode = true;
            //ViewBag.EncryptLastQRC = data.EncryptLastQRC;
            //ViewBag.EncryptLastQRC = ObjQRCModel.EncryptLastQRC + "," + (string.IsNullOrEmpty(objLocationMasterModel.Address2) ? ObjLoginModel.Location.ToString().Substring(0, 3).ToUpper() : objLocationMasterModel.Address2.ToString().Substring(0, 3).ToUpper());
            //ViewBag.ItemAbberivationList = Convert.ToString(ConfigurationManager.AppSettings["ItemAbberivationList"]);

            //if (ObjLoginModel != null && (ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.GlobalAdmin) || ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.ITAdministrator)))
            //{
            //    //ViewBag.ManagerList = _IGlobalAdmin.GetAllITAdministratorList(0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Manager), out Totalrecords);
            //    ViewBag.LocationList = _IGlobalAdmin.GetAllLocationNew();
            //    ViewBag.AdministratorList = _IGlobalAdmin.GetAllITAdministratorList(0, 0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Administrator), out Totalrecords);
            //}
            //else if (ObjLoginModel != null && (ObjLoginModel.UserRoleId == Convert.ToInt64(UserType.Administrator)))
            //{
            //    ViewBag.LocationList = _IGlobalAdmin.GetAllLocationNew();
            //    //ViewBag.AdministratorList = _IGlobalAdmin.GetAllITAdministratorList(0, 1, 1000, "UserEmail", "asc", "", Convert.ToInt64(UserType.Manager), out Totalrecords);
            //    ViewBag.AdministratorList = _ICommonMethod.GetManagersBYLocationId(ObjLoginModel.LocationID);
            //}

            return(View(ObjQRCModel));
            // return RedirectToAction("Index","QRCSetup");
        }
コード例 #2
0
        //CommonMethodAdmin ObjCommonMethodAdmin = new CommonMethodAdmin();
        //Result result;
        //nagendra nov 13 2014
        public Result SaveClient(UserModel objUserModel, out long qrcId, bool IsManagerRegistration, DARModel objDARModel)
        {
            try
            {
                qrcId = 0;
                //QRCName = "Manager"; SpecialNotes = "Manager added successfully";
                ObjUserRepository        = new UserRepository();
                ObjManagerUser           = new UserRegistration();
                objGlobalCodesRepository = new GlobalCodesRepository();
                if (CheckDuplicateUser(objUserModel.UserEmail.Trim(), objUserModel.UserId, out qrcId, objUserModel.AlternateEmail, objUserModel.EmployeeID))
                {
                    objUserModel.IsEmailVerify     = true;
                    objUserModel.IsLoginActive     = true;
                    objUserModel.SubscriptionEmail = objUserModel.UserEmail;

                    if (objUserModel.Gender != null)
                    {
                        objUserModel.Gender = objUserModel.Gender == 1 ? objGlobalCodesRepository.GetSingleOrDefault(g => g.CodeName == "Male").GlobalCodeId : objGlobalCodesRepository.GetSingleOrDefault(g => g.CodeName == "Female").GlobalCodeId;
                    }

                    using (TransactionScope TransScope = new TransactionScope())
                    {
                        if (objUserModel.UserId == 0)
                        {
                            ObjManagerUser.ProfileImage = objUserModel.ProfileImageFile;
                            AutoMapper.Mapper.CreateMap <UserModel, UserRegistration>();
                            ObjManagerUser = AutoMapper.Mapper.Map(objUserModel, ObjManagerUser);
                            ObjManagerUser.ProfileImage = objUserModel.ProfileImageFile;
                            //if (ObjManagerUser.ProfileImage != null)
                            //    ObjManagerUser.ProfileImage = (!string.IsNullOrEmpty(objUserModel.ProfileImage.FileName) ? objUserModel.ProfileImage.FileName : "no-profile-pic.jpg");

                            ObjUserRepository.Add(ObjManagerUser);

                            //ObjUserRepository.SaveChanges();
                            //if (ObjManagerUser != null)
                            //{
                            //    //ObjManagerUser.Password = (string.IsNullOrEmpty(ObjManagerUser.Password)) ? Cryptography.GetDecryptedData(0.ToString(), true) : ObjManagerUser.Password;
                            //    if (_ICommonMethod.GenerateQRCode(QRCName, ManageManagerMODULE, null, null, QRCDefaultSizeID, QRCTYPEID, SpecialNotes, objUserModel.CreatedBy, out QRCID))
                            //    { ObjUserRepository.Add(ObjManagerUser); }
                            //}


                            if (ObjManagerUser.UserId > 0)
                            {
                                objUserModel.Address.UserId = ObjManagerUser.UserId;

                                objAddressManager.SaveAddress(objUserModel.Address);
                                if (objUserModel.UserType == Convert.ToInt64(UserType.GlobalAdmin, CultureInfo.InvariantCulture) ||
                                    objUserModel.UserType == Convert.ToInt64(UserType.ITAdministrator, CultureInfo.InvariantCulture) ||
                                    objUserModel.UserType == Convert.ToInt64(UserType.Administrator, CultureInfo.InvariantCulture)
                                    //Commented by Bhushan on 30/05/2016 for no need to check manager bcoz in below method(objBB.AssignRoleAndPermission) code is doing same
                                    // || objUserModel.UserType == Convert.ToInt64(UserType.Manager, CultureInfo.InvariantCulture)
                                    )
                                {
                                    _ICommonMethodAdmin.AssignLocationToAdminUser(objUserModel.Location, ObjManagerUser.UserId);
                                }

                                Result objResult = _ICommonMethod.SaveDAR(objDARModel);

                                TransScope.Complete();
                                return(Result.Completed);
                            }
                            else
                            {
                                return(Result.Failed);
                            }
                        }
                        else
                        {
                            UpdateUser(objUserModel, out qrcId, IsManagerRegistration);
                            objUserModel.Address.UserId = objUserModel.UserId;
                            objAddressManager.SaveAddress(objUserModel.Address);
                            Result objResult = _ICommonMethod.SaveDAR(objDARModel);
                            TransScope.Complete();
                            return(Result.UpdatedSuccessfully);
                        }
                    }
                }
                else
                {
                    return(Result.DuplicateRecord);
                }
            }
            catch (Exception)
            { throw; }
        }