예제 #1
0
        private void BindInputFileData(string strSortField)
        {
            try
            {
                if (m_objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }

                BSLCompany objCompany     = m_objUser.GetCompany();
                string     strDataDirName = objCompany.TCompanies[0].rootDirName;
                string     strInputDir    = (string)Cache["G2_DATA_PATH"];
                strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                               strDataDirName;
                string strOutputDir = strInputDir;
                strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                               "Input";
                strOutputDir += (!strOutputDir.EndsWith("\\") ? "\\" : "") +
                                "Output";

                DirectoryInfo myDirInfo;
                FileInfo[]    arrFileInfo;
                DataRow       myDataRow;
                DataView      myDataView;

                //Populate Input Grid
                DataTable tblInputFiles = new DataTable();
                tblInputFiles.Columns.Add("fileName", Type.GetType("System.String"));
                tblInputFiles.Columns.Add("fileSize", Type.GetType("System.Int32"));
                tblInputFiles.Columns.Add("modifyDate", Type.GetType("System.DateTime"));
                tblInputFiles.Columns.Add("fileExt", Type.GetType("System.String"));
                myDirInfo = new DirectoryInfo(strInputDir);
                // You can easily filter results by name... I just want a list
                // of all the files, but you could filter here if you wanted.
                //arrFileInfo = myDirInfo.GetFiles("s*.*")
                arrFileInfo = myDirInfo.GetFiles();
                // Loop through array of FileInfo objects placing the data we'll
                // be using into our DataTable for easy manipulation.
                for (int i = 0; i < arrFileInfo.Length; i++)
                {
                    FileInfo myFileInfo = arrFileInfo[i];
                    myDataRow               = tblInputFiles.NewRow();
                    myDataRow["fileName"]   = myFileInfo.Name;
                    myDataRow["fileSize"]   = myFileInfo.Length;
                    myDataRow["modifyDate"] = myFileInfo.LastWriteTime;
                    myDataRow["fileExt"]    = myFileInfo.Extension;
                    tblInputFiles.Rows.Add(myDataRow);
                }
                // Create a new DataView and sort it.
                myDataView               = tblInputFiles.DefaultView;
                myDataView.Sort          = strSortField;
                dataGridInput.DataSource = myDataView;
                dataGridInput.DataBind();
            }
            catch (System.Exception ex)
            {
                lblMsg.Visible = true;
                lblMsg.Text    = ex.Message;
            }
        }
예제 #2
0
        public string StartG2(string strUserName, string strPassword, int portNo)
        {
            LogMsg("StartG2: StartG2 called.");
            DSResponse response = new DSResponse();

            string  strErrMsg = "";
            BSLUser objUser   = GetUser(strUserName, strPassword, ref strErrMsg);

            if (objUser == null)
            {
                response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                return(response.GetXml());
            }

            LogMsg("StartG2: Successfully retrieved user.");

            BSLCompany objCompany = objUser.GetCompany();

            LogMsg("StartG2: Successfully retrieved user's company.");

            LogMsg("StartG2: About to call ShellG2.");

            if (!ShellG2(portNo, objCompany, ref strErrMsg))
            {
                LogMsg("StartG2: " + strErrMsg + " occured in ShellG2.");
                response.G2MgrResponse.AddG2MgrResponseRow("", strErrMsg, 1);
                return(response.GetXml());
            }

            LogMsg("StartG2: Successfully Shelled G2.");

            response.G2MgrResponse.AddG2MgrResponseRow("Started", "", 0);
            return(response.GetXml());

            //			XmlDocument xDoc = new XmlDocument();
            //			xDoc.LoadXml(response.GetXml());
            //			NameTable nt = new NameTable();
            //			XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
            //			nsmgr.AddNamespace("dsresponse", "http://tempuri.org/DSResponse.xsd");
            //			XmlNode nodeErrCode = xDoc.DocumentElement.SelectSingleNode("//dsresponse:errorCode", nsmgr);
            //			if (nodeErrCode.InnerText.Equals("0"))
            //			{
            //				try
            //				{
            //					XmlNode nodeResults = xDoc.DocumentElement.SelectSingleNode("//dsresponse:results", nsmgr);
            //					if (nodeResults != null)
            //					{
            //						string s = nodeResults.InnerText;
            //						DSUser ds2 = new DSUser();
            //						System.Xml.XmlDataDocument xDataDoc = new XmlDataDocument(ds2);
            //						xDataDoc.LoadXml(s);
            //						if (ds2.TUsers.Count > 0)
            //							s = ds2.TUsers[0].firstName;
            //					}
            //				}
            //				catch(Exception ex)
            //				{
            //				}
            //			}
        }
예제 #3
0
        private void OnUpload(object sender, System.EventArgs e)
        {
            try
            {
                if (m_objUser == null)
                {
                    throw new Exception("Your session has expired.");
                }

                System.Web.HttpFileCollection uploadedFiles = Request.Files;
                BSLCompany objCompany     = m_objUser.GetCompany();
                string     strDataDirName = objCompany.TCompanies[0].rootDirName;
                string     strInputDir    = (string)Cache["G2_DATA_PATH"];
                strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                               strDataDirName;
                strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                               "Input";

                for (int i = 0; i < uploadedFiles.Count; i++)
                {
                    System.Web.HttpPostedFile postedFile = uploadedFiles[i];
                    string strFileName = System.IO.Path.GetFileName(postedFile.FileName);
                    postedFile.SaveAs(strInputDir + "\\" + strFileName);
                }
                string strScript = "<script for='window' event='onload' language='javascript'>alert('File(s) uploaded successfully.');</script>";
                RegisterStartupScript("SuccessMsg", strScript);
            }
            catch (Exception ex)
            {
                lblMsg.Visible = true;
                lblMsg.Text    = ex.Message;
            }
        }
예제 #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            BSLUser objUser = (BSLUser)Session["objUser"];

            if ((objUser == null) || (objUser.TUsers[0].inactive))
            {
                return;
            }

            string strDir = Request["d"];

            if ((strDir == null) || (strDir.Length == 0))
            {
                return;
            }

            string strFilename = Request["f"];

            if ((strFilename == null) || (strFilename.Length == 0))
            {
                return;
            }

            BSLCompany objCompany     = objUser.GetCompany();
            string     strDataDirName = objCompany.TCompanies[0].rootDirName;
            string     strInputDir    = (string)Cache["G2_DATA_PATH"];

            strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                           strDataDirName;
            string strOutputDir = strInputDir;

            strInputDir += (!strInputDir.EndsWith("\\") ? "\\" : "") +
                           "Input";
            strOutputDir += (!strOutputDir.EndsWith("\\") ? "\\" : "") +
                            "Output";

            string strSourceDir = "";

            if (strDir.ToLower().Equals("i"))
            {
                strSourceDir = strInputDir;
            }
            else if (strDir.ToLower().Equals("o"))
            {
                strSourceDir = strOutputDir;
            }
            else
            {
                return;
            }

            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=" + strFilename);
            Response.ContentType = "application/download";             //"application/octet-stream"
            string filename = strSourceDir + "\\" + strFilename;

            System.IO.FileStream downloadFile = new System.IO.FileStream(filename,
                                                                         System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            byte[] byteArray = new byte[(int)downloadFile.Length];
            downloadFile.Read(byteArray, 0, (int)downloadFile.Length);
            downloadFile.Close();
            Response.BinaryWrite(byteArray);
            Response.Flush();
            Response.End();
        }