public MDMSVC.DC_Message InsertFileRecord(string Entity, ReRunMode Mode)
        {
            Guid        SupplierImportFile_Id = Guid.NewGuid();
            MappingSVCs _objMappingSVCs       = new MappingSVCs();

            MDMSVC.DC_SupplierImportFileDetails _objFileDetails = new MDMSVC.DC_SupplierImportFileDetails();
            _objFileDetails.SupplierImportFile_Id = SupplierImportFile_Id;
            _objFileDetails.Supplier_Id           = Guid.Parse(ddlSupplierName.SelectedValue);
            _objFileDetails.Entity           = Entity;
            _objFileDetails.OriginalFilePath = "";
            _objFileDetails.SavedFilePath    = "";

            if (Mode == ReRunMode.RERUN)
            {
                _objFileDetails.STATUS = "UPLOADED";
            }
            else if (Mode == ReRunMode.SCHEDULE)
            {
                _objFileDetails.STATUS = "SCHEDULED";
            }

            _objFileDetails.Mode        = "RE_RUN";
            _objFileDetails.CREATE_DATE = DateTime.Now;
            _objFileDetails.CREATE_USER = System.Web.HttpContext.Current.User.Identity.Name;
            MDMSVC.DC_Message _objMsg = _objMappingSVCs.SaveSupplierStaticFileDetails(_objFileDetails);

            if (Mode == ReRunMode.RERUN)
            {
                //file Process logic
                MDMSVC.DC_SupplierImportFileDetails    obj = new MDMSVC.DC_SupplierImportFileDetails();
                MDMSVC.DC_SupplierImportFileDetails_RQ RQ  = new MDMSVC.DC_SupplierImportFileDetails_RQ();
                RQ.SupplierImportFile_Id = SupplierImportFile_Id;
                RQ.PageNo   = 0;
                RQ.PageSize = int.MaxValue;
                var res = _objMappingSVCs.GetSupplierStaticFileDetails(RQ);
                obj.SupplierImportFile_Id = res[0].SupplierImportFile_Id;
                obj.Supplier_Id           = res[0].Supplier_Id;
                obj.Supplier      = res[0].Supplier;
                obj.SavedFilePath = res[0].SavedFilePath;
                obj.PROCESS_USER  = System.Web.HttpContext.Current.User.Identity.Name;
                obj.Entity        = res[0].Entity;
                obj.STATUS        = res[0].STATUS;
                obj.Mode          = res[0].Mode;
                var result = _objMappingSVCs.StaticFileUploadProcessFile(obj);
                //end
                //view File  details
                hdnFileId.Value = SupplierImportFile_Id.ToString();
                ClientScript.RegisterStartupScript(this.GetType(), "showDetailsModal", "showDetailsModal('" + SupplierImportFile_Id + "');", true);
            }
            // Response.Redirect("~/staticdata/files/upload.aspx");

            return(_objMsg);
        }
Beispiel #2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (ddlSupplierList.SelectedValue == "0" || ddlEntityList.SelectedValue == "0")
            {
                BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, "Please select valid supplier & entity before upload.", BootstrapAlertType.Danger);
                return;
            }
            if (FileUpload1.HasFile)
            {
                string strFileType = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).Replace(".", "").ToLower();
                string strSavedValidFileExtension = ValidFile();
                if (strFileType == string.Empty)
                {
                    BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, "Invalid file.", BootstrapAlertType.Danger);
                }
                else if (strSavedValidFileExtension == string.Empty)
                {
                    BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, "No file type has been defined.", BootstrapAlertType.Danger);
                }
                else if (strSavedValidFileExtension == strFileType)
                {
                    Guid FileUploadId   = Guid.NewGuid();
                    long ActualFileSize = FileUpload1.PostedFile.ContentLength;
                    var  response       = UploadFileInChunks(FileUpload1.PostedFile, ActualFileSize, FileUploadId);

                    if (response.UploadSucceeded)
                    {
                        MappingSVCs _objMappingSVCs = new MappingSVCs();
                        MDMSVC.DC_SupplierImportFileDetails _objFileDetails = new MDMSVC.DC_SupplierImportFileDetails();
                        _objFileDetails.SupplierImportFile_Id = FileUploadId;
                        _objFileDetails.Supplier_Id           = Guid.Parse(ddlSupplierList.SelectedValue);
                        _objFileDetails.Entity           = ddlEntityList.SelectedItem.Text;
                        _objFileDetails.OriginalFilePath = FileUpload1.FileName;
                        _objFileDetails.SavedFilePath    = response.UploadedPath;
                        //_objFileDetails.STATUS = "UPLOADED";
                        _objFileDetails.STATUS      = "NEW";
                        _objFileDetails.Mode        = "ALL";
                        _objFileDetails.CREATE_DATE = DateTime.Now;
                        _objFileDetails.CREATE_USER = System.Web.HttpContext.Current.User.Identity.Name;

                        MDMSVC.DC_Message _objMsg = _objMappingSVCs.SaveSupplierStaticFileDetails(_objFileDetails);

                        if (_objMsg.StatusCode == MDMSVC.ReadOnlyMessageStatusCode.Success)
                        {
                            btnReset_Click(null, EventArgs.Empty);
                            BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, _objMsg.StatusMessage, BootstrapAlertType.Success);
                        }
                        else
                        {
                            BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, _objMsg.StatusMessage, BootstrapAlertType.Danger);
                        }
                        _objFileDetails = null;
                        clearControls();
                    }
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, "Please select valid file.", BootstrapAlertType.Danger);
                }
            }
            else
            {
                BootstrapAlert.BootstrapAlertMessage(dvmsgUploadCompleted, "No file has been selected to upload.", BootstrapAlertType.Danger);
            }
        }