Пример #1
0
        protected void SaveAttachment(string filName, string extension, string docKind, string callRefNo, string attachedBlob)
        {
            var usNo     = nav.grantees_Register.ToList().Where(usr => usr.Organization_Username == Session["username"].ToString()).Select(nu => nu.No).SingleOrDefault();
            var usaname  = Session["username"].ToString();
            var taskNum  = Session["tasknumber"].ToString();
            int userType = Convert.ToInt32(Session["usertype"]);
            var prjct    = ddlAccountType.SelectedItem.Text;

            // string fullFPath = Request.PhysicalApplicationPath + "All Uploads\\" + Grantees.No + @"\" + filName;

            string navfilePath = @"D:\All_Portal_Uploaded\" + filName;

            // string uriPath = new Uri(navfilePath).LocalPath;
            // string urI =;

            var       credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
            const int granttype   = 1;
            string    docType     = "";

            if ((extension == ".jpg") || (extension == ".jpeg") || (extension == ".png"))
            {
                docType = "Picture";
            }
            else
            if ((extension == ".pdf"))
            {
                docType = "PDF";
            }
            if ((extension == ".doc") || (extension == ".docx"))
            {
                docType = "Word Document";
            }
            if (extension == ".xlsx")
            {
                docType = "Excel Document";
            }
            //try
            //{

            int slVal = ddlAccountType.SelectedIndex;

            switch (slVal)
            {
            case 0:
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "alert('Select valid project from dropdownlist!');", true);
                txtPrefNo.Text = "";
                break;

            default:
                Portals sup = new Portals();
                sup.Credentials     = credentials;
                sup.PreAuthenticate = true;
                if (sup.FnAttachMatrixx(usNo, docType, navfilePath, filName, granttype, docKind, usaname, prjct, callRefNo, attachedBlob) == true)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "alert('Document: " + filName + " uploaded and Saved successfully!');", true);
                    sup.FnFullfillTask(taskNum, userType);
                }
                break;
            }

            //}
            //catch (Exception r)
            //{
            //    KCDFAlert.ShowAlert(r.Message);
            //}
        }
Пример #2
0
        protected bool SaveAttachmentforTask(string usernumber, string filName, string extension, string docKind, string callRefNo, string attachedBlob)
        {
            var usaname    = Session["username"].ToString();
            var taskNum    = Session["tasknumber"].ToString();
            int userType   = Convert.ToInt32(Session["usertype"]);
            int granttype  = 0;
            var userNumber = "";
            var myyearP    = "";
            var myquarter  = "";
            var prjct      = "";

            if (ddlAccountType.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything",
                                                        "alert('Please Select Project first');", true);
                return(false);
            }
            else
            {
                prjct = ddlAccountType.SelectedItem.Text;
            }

            if (ddlYears.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "alert('Please Choose Year');",
                                                        true);

                return(false);
            }
            else
            {
                myyearP = ddlYears.SelectedItem.Text;
            }

            if (ddlQuarter.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything",
                                                        "alert('Please Choose Quarter');", true);
                return(false);
            }
            else
            {
                myquarter = ddlQuarter.SelectedItem.Text;
            }

            var sessx = Session["reportformUser"].ToString();

            switch (sessx)
            {
            case "iamGrantee":
                granttype  = 0;
                userNumber =
                    nav.grantees_Register.ToList()
                    .Where(u => u.Organization_Username == Session["username"].ToString())
                    .Select(u => u.No)
                    .SingleOrDefault();
                break;

            case "iamStudent":
                granttype  = 1;
                userNumber =
                    nav.studentsRegister.ToList()
                    .Where(u => u.Username == Session["username"].ToString())
                    .Select(u => u.No)
                    .SingleOrDefault();
                break;

            case "iamConsult":
                granttype  = 2;
                userNumber =
                    nav.myConsultants.ToList()
                    .Where(u => u.Organization_Username == Session["username"].ToString())
                    .Select(u => u.No)
                    .SingleOrDefault();
                break;
            }

            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"],
                                                    ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);

            string docType = "";

            if ((extension == ".jpg") || (extension == ".jpeg") || (extension == ".png"))
            {
                docType = "Picture";
            }
            else if ((extension == ".pdf"))
            {
                docType = "PDF";
            }
            if ((extension == ".doc") || (extension == ".docx"))
            {
                docType = "Word Document";
            }
            if (extension == ".xlsx")
            {
                docType = "Excel Document";
            }
            //try
            //{
            Portals sup = new Portals {
                Credentials = credentials, PreAuthenticate = true
            };

            if (sup.FnAttachReportForms(userNumber, docType, filName, granttype, docKind, usaname, prjct, callRefNo, attachedBlob, myyearP, myquarter) == true)
            {
                // KCDFAlert.ShowAlert("Document: " + filName + " uploaded and Saved successfully!");
                // loadUploads();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything",
                                                        "alert('Document: '" + filName + "'successfully uploaded!');", true);
                sup.FnFullfillTask(taskNum, userType);
                return(true);
            }
            return(false);

            //}
            //catch (Exception r)
            //{
            //    KCDFAlert.ShowAlert(r.Message);
            //}
        }