Beispiel #1
0
        public HttpResponseMessage OpenFile([FromBody] OpenDocumentParams data)
        {
            string login    = ConfigurationManager.AppSettings["UploadAccessUserId"].ToString();
            string domain   = ConfigurationManager.AppSettings["UploadAccessDomainName"].ToString();
            string password = Crypt.DecryptData(ConfigurationManager.AppSettings["UploadAccessPassword"].ToString());


            string tokenId    = (data == null || data.tokenId == null) ? "" : data.tokenId;
            string mUserid    = (data == null || data.mUserid == null) ? "" : data.mUserid;
            string DocumentId = (data == null || data.DocumentId == null) ? "" : data.DocumentId;

            //tokenId = Convert.ToString(System.Web.HttpContext.Current.Request.Form["tokenId"]);
            //mUserid = Convert.ToString(System.Web.HttpContext.Current.Request.Form["mUserid"]);
            //DocumentId = Convert.ToString(System.Web.HttpContext.Current.Request.Form["DocumentId"]);


            MobileDataBase.Result rslt = MobileDataBase.GetValidUserDetails(tokenId, mUserid);
            rslt.Data = null;

            try
            {
                if (rslt.status == "0")
                {
                    string SuffixPath = MobileDataBase.GetDocPath(DocumentId, mUserid);
                    string sPath      = "";
                    sPath = Path.Combine(ServerUploadFolder, SuffixPath);
                    if (ConfigurationManager.AppSettings["UploadAccessImpersinationRequired"].ToString() == "Y")
                    {
                        using (UserImpersonation user = new UserImpersonation(login, domain, password))
                        {
                            if (user.ImpersonateValidUser())
                            {
                                return(DownLoadFile(sPath));
                            }
                        }
                    }
                    else
                    {
                        return(DownLoadFile(sPath));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(this.Request.CreateResponse(HttpStatusCode.NotFound, "File not found."));
        }
Beispiel #2
0
        public ActionResponse Upload(string Domain, string UserId, string Password, )
        {
            //string login = ConfigurationManager.AppSettings["UploadAccessUserId"].ToString();
            //string domain = ConfigurationManager.AppSettings["UploadAccessDomainName"].ToString();
            //string password = Crypt.DecryptData(ConfigurationManager.AppSettings["UploadAccessPassword"].ToString());

            //<add key="UploadAccessImpersinationRequired" value="Y" />
            //<add key="UploadAccessUserId" value="SVC_CSMaqasaDocnew" />
            //<add key="UploadAccessDomainName" value="KGACHQ" />
            //<add key="UploadAccessPassword" value="MKjuOI9MZWxxD/StmFdCWqOCX+bngatC" />

            //string tokenId = "";
            //string mUserid = "";
            //string OrgReqId = "", OrgId = "";
            //string DocumentName = "";
            //string DocumentType = "";
            //string eservicerequestid = "";
            //bool ImportLicenseDoc = false;////added newly -  to differentiate if the upload is for Importer license details
            //string LicenseNumber = "", IssuanceDate = "", ExpiryDate = "", LicenseType = "";//added newly - form data passed in ajax request
            //tokenId = Convert.ToString(System.Web.HttpContext.Current.Request.Form["tokenId"]);
            //mUserid = Convert.ToString(System.Web.HttpContext.Current.Request.Form["mUserid"]);
            //DocumentName = Convert.ToString(System.Web.HttpContext.Current.Request.Form["DocumentName"]);
            //DocumentType = Convert.ToString(System.Web.HttpContext.Current.Request.Form["DocumentType"]);
            //ImportLicenseDoc = Convert.ToBoolean(System.Web.HttpContext.Current.Request.Form["ImportLicenseDoc"]);
            //string UploadedFrom = Convert.ToString(System.Web.HttpContext.Current.Request.Form["UploadedFrom"]);


            //eservicerequestid = Convert.ToString(System.Web.HttpContext.Current.Request.Form["eservicerequestid"]);
            //OrgReqId = Convert.ToString(System.Web.HttpContext.Current.Request.Form["OrgReqId"]);
            //OrgId = Convert.ToString(System.Web.HttpContext.Current.Request.Form["OrgId"]);

            if (eservicerequestid != null)
            {
                if (!eservicerequestid.All(char.IsDigit))
                {
                    eservicerequestid = CommonFunctions.CsUploadDecrypt(eservicerequestid.ToString());
                }
            }

            if (!OrgReqId.All(char.IsDigit))
            {
                OrgReqId = CommonFunctions.CsUploadDecrypt(OrgReqId.ToString());
            }



            if (!DocumentType.All(char.IsDigit))
            {
                DocumentType = CommonFunctions.CsUploadDecrypt(DocumentType);
            }
            MobileDataBase.Result rslt = new MobileDataBase.Result();
            if (UploadedFrom != "BRSExamDOCS")
            {
                rslt      = MobileDataBase.GetValidUserDetails(tokenId, mUserid);
                rslt.Data = null;
            }
            {
                rslt.status = "0";
            }
            try
            {
                //  rslt.status = "0";
                if (rslt.status == "0")
                {
                    if (ImportLicenseDoc)//added newly // to differentiate if the upload is for Importer license details
                    {
                        LicenseNumber = Convert.ToString(System.Web.HttpContext.Current.Request.Form["LicenseNumber"]);
                        IssuanceDate  = Convert.ToString(System.Web.HttpContext.Current.Request.Form["IssuanceDate"]);
                        ExpiryDate    = Convert.ToString(System.Web.HttpContext.Current.Request.Form["ExpiryDate"]);
                        LicenseType   = Convert.ToString(System.Web.HttpContext.Current.Request.Form["LicenseType"]);

                        string StatusCode = MobileDataBase.UniqueImporterLicenseCheck(LicenseNumber, OrgReqId, OrgId);
                        if (StatusCode == "-1")
                        {
                            rslt.status = "-11";
                            return(new HttpResponseMessage()
                            {
                                Content = new StringContent(JsonConvert.SerializeObject(rslt, Formatting.None)//Frdata
                                                            , System.Text.Encoding.UTF8, "application/json")
                            });
                        }
                    }

                    if (ConfigurationManager.AppSettings["UploadAccessImpersinationRequired"].ToString() == "Y")
                    {
                        using (UserImpersonation user = new UserImpersonation(UserId, Domain, Password))
                        {
                            if (user.ImpersonateValidUser())
                            {
                                UploadFile(rslt, DocumentName, DocumentType, OrgReqId, OrgId, ImportLicenseDoc, LicenseNumber, IssuanceDate, ExpiryDate, LicenseType);
                            }
                            else
                            {
                                throw new UnauthorizedAccessException("Access failed while uploading.");
                            }
                        }
                    }
                    else
                    {
                        UploadFile(rslt, DocumentName, DocumentType, OrgReqId, OrgId, ImportLicenseDoc, LicenseNumber, IssuanceDate, ExpiryDate, LicenseType);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(rslt, Formatting.None)//Frdata
                                            , System.Text.Encoding.UTF8, "application/json")
            });
        }