Exemple #1
0
        private string ProcessFile(int fileType, string fileDesc, HttpPostedFile file)
        {
            SmartflowLite.UploadDoc doc = new SmartflowLite.UploadDoc(FileNo);
            if (file.FileName.Trim().Equals(""))
            {
                return("");
            }
            int count = doc.SaveFile(file, fileType, fileDesc, this.userID, true);

            this.FileId = doc.FileId;
            if (count == 0)
            {
                return("");
            }
            if (count == -1)
            {
                return("Error in saving File " + doc.FileName + ".");
            }
            else if (count == -3)
            {
                return("Error in PDF Conversion of File " + doc.FileName + " ");
            }
            else
            {
                return("Error in saving File Information of File " + doc.FileName + " ");
            }
        }
Exemple #2
0
        protected void btnUpload_Click()
        {
            this.WfId   = Convert.ToInt32((string)Request.QueryString["wfid"]);
            this.FileNo = GetFileNo(WfId);
            if (dllFileType.SelectedItem.ToString() == "Invoice")
            {
                if (CheckInput())
                {
                    return;
                }
            }
            if (dllFileType.SelectedItem.ToString() == "Other")
            {
                if (txtDesc.Text.Trim() == "")
                {
                    lblmsg.Text = "Description is required for document type of 'Other'";
                }
                this.descRow.Style.Add("display", "");
            }

            if (this.FileUpload.PostedFile.FileName.Trim().Equals(""))
            {
                lblmsg.Text    = "Please select 'Choose Files' before clicking Upload Files.";
                lblmsg.Visible = true;
                return;
            }

            int    lastPos = FileUpload.PostedFile.FileName.Trim().LastIndexOf(@".");
            string suffix  = FileUpload.PostedFile.FileName.Trim().Substring(lastPos);

            if (suffix.ToLower() == ".pdf" || suffix.ToLower() == ".jpg" || suffix.ToLower() == ".jpeg")
            {
                lblmsg.Text = "";
            }
            else
            {
                lblmsg.Text    = "Please upload only PDF or images";
                lblmsg.Visible = true;
                return;
            }
            if (lblmsg.Text == "")
            {
                HttpFileCollection uploadedFiles = Request.Files;
                string             errorList     = "";
                DataAccess         dba           = new DataAccess();
                for (int i = 0; i < uploadedFiles.Count; i++)
                {
                    HttpPostedFile file = uploadedFiles[i];

                    try
                    {
                        if (file.ContentLength > 0)
                        {
                            if (!file.FileName.Trim().Equals(""))
                            {
                                string descriptor = this.txtDesc.Text;
                                if (descriptor == "")
                                {
                                    descriptor = this.dllFileType.SelectedItem.ToString();
                                }
                                int ftyp = Convert.ToInt32(this.dllFileType.SelectedValue);
                                errorList += this.ProcessFile(ftyp, descriptor, file);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                        //Span1.Text += "Error: <br>" + Ex.Message;
                    }
                }
                if (errorList == "")
                {
                    if (uploadedFiles.Count > 1)
                    {
                        string strDBfilePath = dba.dxGetSPString("wfGetFilesRootPath");
                        string File;

                        string filePath;
                        filePath = strDBfilePath;
                        if (WfId > 0)
                        {
                            filePath += WfId + @"\";
                        }

                        for (int i = 1; i < uploadedFiles.Count; i++)
                        {
                            HttpPostedFile file  = uploadedFiles[i];
                            string         File1 = filePath + SetFileName(file);

                            File = filePath + SetFileName(uploadedFiles[0]);

                            MergeFile(File, File1);

                            int filekeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + SetFileName(file) + "'");
                            if (filekeyId > 0)
                            {
                                SmartflowLite.UploadDoc doc = new SmartflowLite.UploadDoc(filekeyId);
                                string message  = "";
                                int    delCount = doc.DeleteFile(ref message);
                            }
                        }
                        File = filePath + SetFileName(uploadedFiles[0]);
                        System.IO.File.Delete(File.Replace(".pdf", ".jpg"));
                    }
                    HttpPostedFile firstfile = uploadedFiles[0];

                    string fileonly = firstfile.FileName.Trim().Substring(firstfile.FileName.Trim().LastIndexOf("\\") + 1);
                    int    OAid     = dba.dxGetIntData("select projmanagerid from claimvalues where wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString());
                    if (dllFileType.SelectedItem.ToString() == "Inspection Report/Estimate")
                    {
                        createGeneralTask(OAid);
                    }

                    if (dllFileType.SelectedItem.ToString() == "Customer Authorization (Emergency)")
                    {
                        Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999);
                        pr.CreateTasks(WfId, SubProcessId, 22435, userID);
                        int KeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'");
                        dba.dxExecuteNonQuery("update wfdet set sindexid=" + KeyId + " where actionid=22436 and wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString());
                    }

                    if (dllFileType.SelectedItem.ToString().Contains("Scope Document"))
                    {
                        Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999);

                        if (dllFileType.SelectedItem.ToString().Contains("Emergency"))
                        {
                            pr.CreateTasks(WfId, 1, 22395, userID);
                        }
                        else
                        {
                            pr.CreateTasks(WfId, 2, 22395, userID);
                        }
                    }
                    int keyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'");
                    if (keyId < 0)
                    {
                        lastPos  = fileonly.LastIndexOf(@".");
                        suffix   = fileonly.Substring(lastPos);
                        fileonly = fileonly.Replace(suffix, ".pdf");
                        keyId    = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'");
                    }
                    //this.FileId = keyId;
                    dba.dxExecuteNonQuery("update StrFilesDet set refId=" + this.schId + " where keyId=" + FileId.ToString());

                    if (dllFileType.SelectedItem.ToString().Contains("Invoice"))
                    {
                        dba.dxExecuteNonQuery("update StrFilesDet set FileId=20, Comments='AP Invoice' where keyId=" + FileId.ToString());
                        Save();
                    }

                    string myStringVariable = "File upload and conversion succesfull";
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
                    //Response.Redirect("Claims.aspx");
                }
                else
                {
                    lblmsg.Text = errorList;
                }
            }
        }