Beispiel #1
0
        //
        // It returns a reference path
        //
        public static string getReferenceFilePathName(string path)
        {
            string filePathName          = path;
            string referencePathFileName = "";

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Get template folder
            var clientFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.CLIENTFOLDER);

            if (filePathName.Contains(templateFolder))
            {
                referencePathFileName =
                    filePathName.Replace(templateFolder, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);
            }

            if (filePathName.Contains(clientFolder))
            {
                referencePathFileName =
                    filePathName.Replace(clientFolder, FCMConstant.SYSFOLDER.CLIENTFOLDER);
            }

            if (string.IsNullOrEmpty(referencePathFileName))
            {
                referencePathFileName = path;
            }

            return(referencePathFileName);
        }
Beispiel #2
0
        private void OLDLogoDoubleClick(object sender, EventArgs e)
        {
            // Show file dialog
            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                // Extract File Path
                string pathOnly = fullPathFileName.Replace(fileName, "");

                // Get Company Logo
                //
                ReportMetadata rmd = new ReportMetadata();
                rmd.ClientUID  = Utils.ClientID;
                rmd.RecordType = FCMConstant.MetadataRecordType.CLIENT;
                rmd.FieldCode  = "COMPANYLOGO";

                rmd.Read(clientUID: Utils.ClientID, fieldCode: "COMPANYLOGO");

                rmd.InformationType = MackkadoITFramework.Helper.Utils.InformationType.IMAGE;
                rmd.ClientType      = "";
                rmd.CompareWith     = "";
                rmd.Description     = "Company";
                // rmd.Condition = fullPathFileName;
                var logoFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGOFOLDER);

                // rmd.Condition = logoFolder + fileName;

                // The intention is to save the reference path %XXX%
                //
                rmd.Condition = FCMConstant.SYSFOLDER.LOGOFOLDER + fileName;

                txtLogo1Location.Text = rmd.Condition;

                rmd.Save();

                Bitmap MyImage;
                pbxLogo.SizeMode = PictureBoxSizeMode.StretchImage;
                if (rmd.Condition != null)
                {
                    // MyImage = new Bitmap(rmd.Condition);
                    string logoLocation = logoFolder + fileName;
                    MyImage       = new Bitmap(logoLocation);
                    pbxLogo.Image = (Image)MyImage;
                }
            }
        }
Beispiel #3
0
        ///// <summary>
        ///// Open document for Document type
        ///// </summary>
        ///// <param name="document"></param>
        //public static void OpenDocument(Document.Document document, object vkReadOnly)
        //{
        //    if (document.DocumentType == Utils.DocumentType.WORD)
        //    {
        //        string filePathName =
        //            Utils.getFilePathName(document.Location,
        //                                  document.Name );

        //        WordDocumentTasks.OpenDocument(filePathName, vkReadOnly);
        //    }

        //}

        // Open document for Location and Name
        //
        public static ResponseStatus OpenDocument(string Location, string Name, string Type, object vkReadOnly, bool isFromWeb)
        {
            if (Type == DocumentType.WORD)
            {
                string filePathName =
                    getFilePathName(Location,
                                    Name);

                var response = WordDocumentTasks.OpenDocument(filePathName, vkReadOnly, isFromWeb);

                if (response.ReturnCode < 1)
                {
                    return(response);
                }
            }

            if (Type == DocumentType.EXCEL)
            {
                string filePathName =
                    getFilePathName(Location,
                                    Name);

                var response = ExcelSpreadsheetTasks.OpenDocument(filePathName);
                if (response.ReturnCode < 1)
                {
                    return(response);
                }
            }
            if (Type == DocumentType.PDF)
            {
                string filePathName =
                    getFilePathName(Location,
                                    Name);
                Process proc  = new Process();
                var     adobe = CodeValue.GetCodeValueExtended(iCodeType: MakConstant.CodeTypeString.SYSTSET, iCodeValueID: "PDFEXEPATH");

                if (!File.Exists(adobe))
                {
                    MessageBox.Show("I can't find Adobe Reader. Please configure SYSTSET.PDFEXTPATH.");

                    var error = new ResponseStatus(MessageType.Error);
                    error.Message = "Adobe Reader can't be found. Please configure SYSTSET.PDFEXTPATH.";
                    return(error);
                }

                proc.StartInfo.FileName  = adobe;
                proc.StartInfo.Arguments = filePathName;
                proc.Start();
            }

            return(new ResponseStatus(MessageType.Informational));
        }
Beispiel #4
0
        /// <summary>
        /// Get file details from file name
        /// </summary>
        private void FileSelected(string fileName, string fullPathFileName)
        {
            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Extract File Path
            string pathOnly = fullPathFileName.Replace(fileName, "");

            txtFileName.Text = fileName;
            txtLocation.Text = pathOnly;

            string pathPartToCheck = "";

            if (pathOnly.Length >= templateFolder.Length)
            {
                pathPartToCheck = pathOnly.Substring(0, templateFolder.Length);
            }
            else
            {
                pathPartToCheck = pathOnly;
            }

            if (pathPartToCheck != templateFolder)
            {
                txtFileName.Text = "";
                txtLocation.Text = "";

                MessageBox.Show("Please select file from allowed folder. " + templateFolder);
                return;
            }

            // Get reference path
            //
            string refPath =
                Utils.getReferenceFilePathName(txtLocation.Text);

            txtLocation.Text = refPath;

            // This is the name of the document and not the file name
            // If it is already set for the client, there is no need
            // to replace it. The idea here is to suggest a name only
            // when the document is being created.
            //
            if (string.IsNullOrEmpty(txtName.Text))
            {
                txtName.Text = fileName.Substring(0, fileName.Length - 4);
            }

            txtFileName.Text = fileName;
        }
Beispiel #5
0
        private void loadDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tvFileList.Nodes.Count <= 0)
            {
                MessageBox.Show("Root node is missing. Please contact technical support.");
                return;
            }
            //
            // Get selected document from tree
            //
            TreeNode tndocSelected    = tvFileList.SelectedNode;
            Document treeSelectedDoco = new Document();

            if (tndocSelected == null)
            {
                tvFileList.SelectedNode = tvFileList.Nodes[0];
                tndocSelected           = tvFileList.SelectedNode;
            }

            treeSelectedDoco = (Document)tndocSelected.Tag; // Cast

            var templateFolder = CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, MakConstant.SYSFOLDER.TEMPLATEFOLDER);

            folderBrowserDialog1.ShowNewFolderButton = false;
            folderBrowserDialog1.SelectedPath        = templateFolder;
            folderBrowserDialog1.RootFolder          = Environment.SpecialFolder.Desktop;

            folderBrowserDialog1.ShowDialog();

            if (string.IsNullOrEmpty(folderBrowserDialog1.SelectedPath))
            {
                return;
            }

            string folderSelected = folderBrowserDialog1.SelectedPath;

            var resp =
                MessageBox.Show("Load Directory", "Are you sure? ", MessageBoxButtons.YesNo);

            if (resp == DialogResult.Yes)
            {
                var uioutput = new Windows.UIOutputMessage();
                uioutput.Show();

                var response = Utils.LoadFolder(folderSelected, uioutput, treeSelectedDoco.UID, 0, HeaderInfo.Instance);
                MessageBox.Show(response.Message, "Load Folder", MessageBoxButtons.OK, response.Icon);
            }

            loadDocumentList(HeaderInfo.Instance);
        }
Beispiel #6
0
        private void btnSourceLocation_Click(object sender, EventArgs e)
        {
            // Separate the file name from the path
            // Store both in separate fields
            //

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Show file dialog
            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                // Extract File Path
                string pathOnly = fullPathFileName.Replace(fileName, "");

                txtSourceFileName.Text = fileName;
                txtSourceLocation.Text = pathOnly;

                // Get reference path
                //
                string refPath =
                    Utils.getReferenceFilePathName(txtSourceLocation.Text);
                txtSourceLocation.Text = refPath;

                // If the source folder includes %TEMPLATEFOLDER%
                // keep the normal rules
                // otherwise, reset the path to %CLIENTFOLDER%\Unique
                // make file name the same
                if (txtSourceLocation.Text.Contains(FCMConstant.SYSFOLDER.TEMPLATEFOLDER))
                {
                    txtLocation.Text = Utils.getOppositePath(txtSourceLocation.Text);
                    txtFileName.Text = txtSourceFileName.Text;
                }
                else
                {
                    txtLocation.Text = FCMConstant.SYSFOLDER.CLIENTFOLDER;
                    txtFileName.Text = txtSourceFileName.Text;
                }
            }
        }
Beispiel #7
0
        // It transforms the reference path into a physical path and add name to it
        //
        public static string GetPathName(string path)
        {
            string filePathName     = path;
            string fullPathFileName = "";

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Get main client folder
            var clientFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.CLIENTFOLDER);

            // Get version folder
            var versionFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.VERSIONFOLDER);

            // Get logo folder
            var logoFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGOFOLDER);

            if (filePathName.Contains(FCMConstant.SYSFOLDER.TEMPLATEFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.TEMPLATEFOLDER, templateFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.CLIENTFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.CLIENTFOLDER, clientFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.VERSIONFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.VERSIONFOLDER, versionFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.LOGOFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.LOGOFOLDER, logoFolder);
            }

            return(fullPathFileName);
        }
Beispiel #8
0
        private void pbxLogo_DoubleClick(object sender, EventArgs e)
        {
            // Show file dialog
            var logoFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGOFOLDER);

            openFileDialog1.InitialDirectory = logoFolder;

            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                // Extract File Path
                string pathOnly = fullPathFileName.Replace(fileName, "");

                if (pathOnly.ToUpper() != logoFolder.ToUpper())
                {
                    MessageBox.Show("Logo must be selected from folder " + logoFolder);
                    return;
                }


                txtLogo1Location.Text = FCMConstant.SYSFOLDER.LOGOFOLDER + fileName;

                Bitmap MyImage;
                pbxLogo.SizeMode = PictureBoxSizeMode.StretchImage;
                if (logoFolder != null)
                {
                    // MyImage = new Bitmap(rmd.Condition);
                    string logoLocation = logoFolder + fileName;
                    try
                    {
                        MyImage       = new Bitmap(logoLocation);
                        pbxLogo.Image = (Image)MyImage;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error importing file. Please try another file type. File Location: " + logoLocation + " >> System Message " + ex.ToString());
                    }
                }
            }
        }
Beispiel #9
0
        // Open document for Location and Name
        //
        public static void OpenDocument(string Location, string Name, string Type, object vkReadOnly, bool isFromWeb = false)
        {
            if (Type == MackkadoITFramework.Helper.Utils.DocumentType.WORD)
            {
                string filePathName =
                    Utils.getFilePathName(Location,
                                          Name);

                WordDocumentTasks.OpenDocument(filePathName, vkReadOnly, isFromWeb);
            }

            if (Type == MackkadoITFramework.Helper.Utils.DocumentType.EXCEL)
            {
                string filePathName =
                    Utils.getFilePathName(Location,
                                          Name);

                var Response = ExcelSpreadsheetTasks.OpenDocument(filePathName);
                if (Response.ReturnCode < 1)
                {
                    MessageBox.Show(Response.Message);
                }
            }
            if (Type == MackkadoITFramework.Helper.Utils.DocumentType.PDF)
            {
                string filePathName =
                    Utils.getFilePathName(Location,
                                          Name);
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                var adobe = CodeValue.GetCodeValueExtended(iCodeType: FCMConstant.CodeTypeString.SYSTSET, iCodeValueID: "PDFEXEPATH");

                if (!File.Exists(adobe))
                {
                    MessageBox.Show("I can't find Adobe Reader. Please configure SYSTSET.PDFEXTPATH.");
                    return;
                }

                proc.StartInfo.FileName  = adobe;
                proc.StartInfo.Arguments = filePathName;
                proc.Start();
            }
        }
Beispiel #10
0
        // Print document for Location and Name
        //
        public static void PrintDocument(string Location, string Name, string Type)
        {
            if (Type == Utils.DocumentType.WORD)
            {
                string filePathName =
                    Utils.getFilePathName(Location, Name);

                WordDocumentTasks.PrintDocument(filePathName);
            }

            if (Type == Utils.DocumentType.EXCEL)
            {
                string filePathName =
                    Utils.getFilePathName(Location, Name);

                var Response = ExcelSpreadsheetTasks.PrintDocument(filePathName);
                if (Response.ReturnCode < 1)
                {
                    MessageBox.Show(Response.Message);
                }
            }
            if (Type == Utils.DocumentType.PDF)
            {
                string filePathName =
                    Utils.getFilePathName(Location, Name);
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                var adobe = CodeValue.GetCodeValueExtended(iCodeType: FCMConstant.CodeTypeString.SYSTSET, iCodeValueID: "PDFEXEPATH");

                if (!File.Exists(adobe))
                {
                    MessageBox.Show("I can't find Adobe Reader. Please configure SYSTSET.PDFEXTPATH.");
                    return;
                }

                proc.StartInfo.FileName = adobe;
                // Print PDF
                proc.StartInfo.Arguments = " /h /p " + filePathName;
                proc.Start();
            }
        }
Beispiel #11
0
        private void btnLocation_Click(object sender, EventArgs e)
        {
            // Separate the file name from the path
            // Store both in separate fields
            //

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Show file dialog
            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                txtCondition.Text = fullPathFileName;
            }
        }
Beispiel #12
0
        // It transforms the reference path into a physical path and add name to it
        //
        public static string getFilePathName(string path, string name)
        {
            string filePathName     = path + "\\" + name;
            string fullPathFileName = "";

            var fcmPort = CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT);
            var fcmHost = CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS);

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended("SYSTSET", FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Get template folder
            var clientFolder =
                CodeValue.GetCodeValueExtended("SYSTSET", FCMConstant.SYSFOLDER.CLIENTFOLDER);

            // Get version folder
            var versionFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.VERSIONFOLDER);

            // Get logo folder
            var logoFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGOFOLDER);

            // Get log file folder
            var logFileFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGFILEFOLDER);



            // WEB

            if (Utils.FCMenvironment == MackkadoITFramework.Helper.Utils.EnvironmentList.WEB)
            {
                string rpath = path.Replace(@"\", @"/");
                path = rpath;

                // Different for WEB
                filePathName = path + @"/" + name;

                // ----------------------
                // Get WEB template folder
                // ----------------------
                templateFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.WEBTEMPLATEFOLDER);

                templateFolder = templateFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT, fcmPort);
                templateFolder = templateFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS, fcmHost);

                // ----------------------
                // Get WEB client folder
                // ----------------------
                clientFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.WEBCLIENTFOLDER);

                clientFolder = clientFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT, fcmPort);
                clientFolder = clientFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS, fcmHost);

                // ----------------------
                // Get WEB version folder
                // ----------------------
                versionFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.WEBVERSIONFOLDER);

                versionFolder = versionFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT, fcmPort);
                versionFolder = versionFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS, fcmHost);

                // ----------------------
                // Get WEB logo folder
                // ----------------------
                logoFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.WEBLOGOFOLDER);

                logoFolder = logoFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT, fcmPort);
                logoFolder = logoFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS, fcmHost);

                // --------------------------------------------------------------
                // Get WEB LOG folder - This is LOG for recording what happened
                // --------------------------------------------------------------
                logFileFolder =
                    CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.LOGFILEFOLDER);

                logFileFolder = logFileFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.WEBPORT, fcmPort);
                logFileFolder = logFileFolder.Replace(MackkadoITFramework.Helper.Utils.SYSTSET.HOSTIPADDRESS, fcmHost);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.TEMPLATEFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.TEMPLATEFOLDER, templateFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.CLIENTFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.CLIENTFOLDER, clientFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.VERSIONFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.VERSIONFOLDER, versionFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.LOGOFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.LOGOFOLDER, logoFolder);
            }

            if (filePathName.Contains(FCMConstant.SYSFOLDER.LOGFILEFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(FCMConstant.SYSFOLDER.LOGFILEFOLDER, logFileFolder);
            }

            if (string.IsNullOrEmpty(fullPathFileName))
            {
                fullPathFileName = path + "\\" + name;
            }

            fullPathFileName = fullPathFileName.Replace("\r", "");

            return(fullPathFileName);
        }
Beispiel #13
0
        // -----------------------------------------------------
        //    Create new document version
        // -----------------------------------------------------
        public ResponseStatus NewVersion(HeaderInfo headerInfo)
        {
            ResponseStatus response = new ResponseStatus();

            response.Message = "New version created successfully.";

            // Copy existing version to old folder version
            // Old folder comes from %VERSIONFOLDER%
            //
            var versionFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.VERSIONFOLDER);

            // Create a record to point to the old version
            var documentVersion = new DocumentVersion();

            documentVersion.FKDocumentCUID = this.CUID;
            documentVersion.FKDocumentUID  = this.UID;

            // Generate the new version id
            documentVersion.IssueNumber = this.IssueNumber;
            documentVersion.Location    = Utils.GetVersionPath(this.Location);
            documentVersion.FileName    = this.FileName;
            documentVersion.Add();

            // Increments issue number
            this.IssueNumber++;

            // Create a new file name with version on it
            // POL-05-01 FILE NAME.doc
            //
            int    version  = Convert.ToInt32(this.IssueNumber);
            string tversion = version.ToString().PadLeft(2, '0');
            // string simpleFileName = this.Name.Substring(10).Trim();
            string simpleFileName = this.Name.Substring(07).Trim();

            string newFileName = this.CUID + '-' +
                                 tversion + '-' +
                                 simpleFileName;

            // string newFileNameWithExtension = newFileName + ".doc";

            // Well, the simple file name has extension already... so I have commented out the line above
            // 30/04/2011 - Testing to see if it works.
            //
            string newFileNameWithExtension = newFileName;

            // Copy the file with new name
            // Let's copy the document
            string realLocation        = Utils.getFilePathName(this.Location, this.FileName);
            string realDestination     = Utils.getFilePathName(documentVersion.Location, documentVersion.FileName);
            string realPathDestination = Utils.GetPathName(documentVersion.Location);

            if (!System.IO.Directory.Exists(realPathDestination))
            {
                System.IO.Directory.CreateDirectory(realPathDestination);
            }

            if (!System.IO.File.Exists(realLocation))
            {
                response.Message    = "File to be copied was not found. " + realLocation;
                response.ReturnCode = -0010;
                response.ReasonCode = 0001;
                response.UniqueCode = ResponseStatus.MessageCode.Error.FCMERR00000006;
                return(response);
            }
            File.Copy(realLocation, realDestination, true);

            // Copy file to new name
            //
            string newFilePathName = Utils.getFilePathName(
                this.Location,
                newFileNameWithExtension);

            File.Copy(realLocation, newFilePathName, true);

            // Delete old version from main folder
            //
            File.Delete(realLocation);

            // Update document details - version, name, etc
            this.IssueNumber = version;
            // this.ComboIssueNumber = "C" + version.ToString("000");
            this.FileName = newFileNameWithExtension;
            this.Name     = newFileName;
            this.UpdateVersion(headerInfo);

            // Build a screen to browse all versions of a file
            // Allow compare/ View
            // Check how to open a document read-only for users future

            response.Contents = version;
            return(response);
        }
Beispiel #14
0
        // It transforms the reference path into a physical path and add name to it
        //
        public static string getFilePathNameLOCAL(string path, string name = "")
        {
            string filePathName = "";

            if (string.IsNullOrEmpty(name))
            {
                filePathName = path;
            }
            else
            {
                filePathName = path + "\\" + name;
            }

            string fullPathFileName = "";

            var fcmPort = CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, SYSTSET.WEBPORT);
            var fcmHost = CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, SYSTSET.HOSTIPADDRESS);

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended("SYSTSET", MakConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Get template folder
            var clientFolder =
                CodeValue.GetCodeValueExtended("SYSTSET", MakConstant.SYSFOLDER.CLIENTFOLDER);

            // Get version folder
            var versionFolder =
                CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, MakConstant.SYSFOLDER.VERSIONFOLDER);

            // Get logo folder
            var logoFolder =
                CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, MakConstant.SYSFOLDER.LOGOFOLDER);

            // Get log file folder
            var logFileFolder =
                CodeValue.GetCodeValueExtended(MakConstant.CodeTypeString.SYSTSET, MakConstant.SYSFOLDER.LOGFILEFOLDER);



            if (filePathName.Contains(MakConstant.SYSFOLDER.TEMPLATEFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(MakConstant.SYSFOLDER.TEMPLATEFOLDER, templateFolder);
            }


            if (filePathName.Contains(MakConstant.SYSFOLDER.CLIENTFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(MakConstant.SYSFOLDER.CLIENTFOLDER, clientFolder);
            }

            if (filePathName.Contains(MakConstant.SYSFOLDER.VERSIONFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(MakConstant.SYSFOLDER.VERSIONFOLDER, versionFolder);
            }

            if (filePathName.Contains(MakConstant.SYSFOLDER.LOGOFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(MakConstant.SYSFOLDER.LOGOFOLDER, logoFolder);
            }

            if (filePathName.Contains(MakConstant.SYSFOLDER.LOGFILEFOLDER))
            {
                fullPathFileName =
                    filePathName.Replace(MakConstant.SYSFOLDER.LOGFILEFOLDER, logFileFolder);
            }

            if (String.IsNullOrEmpty(fullPathFileName))
            {
                fullPathFileName = path + "\\" + name;
            }

            fullPathFileName = fullPathFileName.Replace("\r", "");

            return(fullPathFileName);
        }
Beispiel #15
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            // Separate the file name from the path
            // Store both in separate fields
            //

            // Get template folder
            var templateFolder =
                CodeValue.GetCodeValueExtended(FCMConstant.CodeTypeString.SYSTSET, FCMConstant.SYSFOLDER.TEMPLATEFOLDER);

            // Show file dialog
            openFileDialog1.InitialDirectory = templateFolder;
            openFileDialog1.Filter           = "*.doc|*.xls|*.xlsx|*.docx";
            openFileDialog1.FileName         = "*";

            var file = openFileDialog1.ShowDialog();

            if (file == DialogResult.OK)
            {
                // Only File Name
                string fileName = openFileDialog1.SafeFileName;
                // Full Path including file name
                string fullPathFileName = openFileDialog1.FileName;

                // Extract File Path
                string pathOnly = fullPathFileName.Replace(fileName, "");

                txtFileName.Text = fileName;
                txtLocation.Text = pathOnly;

                string pathPartToCheck = "";

                if (pathOnly.Length >= templateFolder.Length)
                {
                    pathPartToCheck = pathOnly.Substring(0, templateFolder.Length);
                }
                else
                {
                    pathPartToCheck = pathOnly;
                }

                if (pathPartToCheck != templateFolder)
                {
                    txtFileName.Text = "";
                    txtLocation.Text = "";

                    MessageBox.Show("Please select file from allowed folder. " + templateFolder);
                    return;
                }

                // Get reference path
                //
                string refPath =
                    Utils.getReferenceFilePathName(txtLocation.Text);
                txtLocation.Text = refPath;

                // This is the name of the document and not the file name
                // If it is already set for the client, there is no need
                // to replace it. The idea here is to suggest a name only
                // when the document is being created.
                //
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    txtName.Text = openFileDialog1.SafeFileName.Substring(0,
                                                                          openFileDialog1.SafeFileName.Length - 4);
                }

                txtFileName.Text = openFileDialog1.SafeFileName;

                // 03.04.2013
                // CLA-00-00
                txtDisplayName.Text  = txtFileName.Text;
                txtCUID.Text         = txtFileName.Text.Substring(0, 6);
                cbxDocumentType.Text = "WORD";
                cbxRecordType.Text   = FCMConstant.RecordType.DOCUMENT;

                if (txtFileName.Text.Length >= 10)
                {
                    txtSimpleFileName.Text = txtFileName.Text.Substring(10, txtFileName.Text.Length - 10);
                }

                enableSave(sender, e);
            }
        }