Exemple #1
0
        private bool SaveSetting()
        {
            var connData = new ConnectionValuesModel
            {
                Server   = txt_server.Text,
                Database = txt_database.Text,
                User     = txt_user.Text,
                Password = txt_password.Text
            };

            var result = FileFunctions.WriteConnectionData(connData);

            if (result.Success)
            {
                lbl_Message.ForeColor = Color.Green;
                lbl_Message.Text      = result.Message;
                return(true);
            }
            else
            {
                lbl_Message.ForeColor = Color.Maroon;
                lbl_Message.Text      = result.Message;
                return(false);
            }
        }
Exemple #2
0
 public void demo()
 {
     string[] desktopWindowsCaptions = GetDesktopWindowsCaptions();
     foreach (string caption in desktopWindowsCaptions)
     {
         FileFunctions.fConsoleWrite(caption);
     }
 }
        private void btnDeSerializeServiceConfiguration_Click(object sender, EventArgs e)
        {
            String xml = FileFunctions.OpenTextFile("BPConfig.xml");
            ServiceConfigurationCollection list =
                (ServiceConfigurationCollection)SerializationFunctions.DeserializeFromXml(typeof(ServiceConfigurationCollection), xml);

            txtCollection.Text = SerializationFunctions.SerializeToXml(list);
        }
        public static void ReceiveFile(NetworkStream networkStream)
        {
            IFileFunctions fileFunctions = new FileFunctions();
            IFileHandler   fileHandler   = new FileHandler(networkStream);
            IFileService   fileService   = new FileService(fileFunctions, fileHandler);

            fileService.ReceiveFile();
        }
Exemple #5
0
        private string ServerMapFolder(string resourceType, string folderPath)
        {
            string sResourceTypePath = Path.Combine(this.UserFilesDirectory, resourceType);

            FileFunctions.CreateDirectory(sResourceTypePath);

            return(Path.Combine(sResourceTypePath, folderPath.TrimStart('/')));
        }
Exemple #6
0
        /// <summary>
        /// Busca el archivo  lo carga a _Services que es un ServiceConfigurationCollection
        /// </summary>
        ///<param name="xmlConfigFile"></param>
        /// <returns></returns>
        /// <date>2007-07-13T00:00:00</date>
        /// <author>moviedo</author>
        static ServiceConfigurationCollection LoadAllServices(string xmlConfigFile)
        {
            try
            {
                if (!System.IO.File.Exists(xmlConfigFile))

                {
                    //Application.StartupPath
                    xmlConfigFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), xmlConfigFile);
                }

                String xml = FileFunctions.OpenTextFile(xmlConfigFile);
                return((ServiceConfigurationCollection)SerializationFunctions.DeserializeFromXml(typeof(ServiceConfigurationCollection), xml));
            }
            catch (System.IO.IOException ioex)
            {
                TechnicalException te = new TechnicalException(Fwk.Bases.Properties.Resources.ServiceManagement_SourceInfo_Error, ioex);
                if (string.IsNullOrEmpty(ConfigurationsHelper.HostApplicationName))
                {
                    te.Source = string.Concat("Despachador de servicios en ", Environment.MachineName);
                }
                else
                {
                    te.Source = ConfigurationsHelper.HostApplicationName;
                }

                te.ErrorId   = "7004";
                te.Assembly  = typeof(XmlServiceConfigurationManager).AssemblyQualifiedName;
                te.Class     = typeof(XmlServiceConfigurationManager).Name;
                te.Namespace = typeof(XmlServiceConfigurationManager).Namespace;
                throw te;
            }
            catch (TechnicalException te)
            {
                throw te;
            }
            catch (Exception ex)
            {
                string strError = string.Concat("Error al inicializar la metadata de los servicios  \r\n ",
                                                "Nombre de archivo :", xmlConfigFile, Environment.NewLine);

                Fwk.Exceptions.TechnicalException te = new Fwk.Exceptions.TechnicalException(strError, ex);

                if (string.IsNullOrEmpty(ConfigurationsHelper.HostApplicationName))
                {
                    te.Source = string.Concat("Despachador de servicios en ", Environment.MachineName);
                }
                else
                {
                    te.Source = ConfigurationsHelper.HostApplicationName;
                }
                te.ErrorId   = "7004";
                te.Assembly  = typeof(XmlServiceConfigurationManager).AssemblyQualifiedName;
                te.Class     = typeof(XmlServiceConfigurationManager).Name;
                te.Namespace = typeof(XmlServiceConfigurationManager).Namespace;
                throw te;
            }
        }
Exemple #7
0
        public void GetWorksheetCount()
        {
            //Arrange
            FileFunctions fileFunction   = new FileFunctions();
            string        fileName       = Global.fSITest_XLSM;
            int           workSheetCount = fileFunction.WorkSheetCount(fileName);

            Assert.Greater(workSheetCount, 0);
        }
Exemple #8
0
        public void CanOpenWorkBookCXML()
        {
            FileFunctions fileFunctions = new FileFunctions();
            XLWorkbook    workBook      = fileFunctions.OpenWorkBookCXML(Global.testLocation, Global.fSITest_XLSM);
            string        type          = workBook.GetType().ToString();

            Assert.IsTrue(workBook.GetType().ToString() == "ClosedXML.Excel.XLWorkbook");
            workBook.Dispose();
        }
Exemple #9
0
 public async static void StartUP()
 {
     TorrentClientAPI.StartItAllV2();
     if (File.Exists(Environment.CurrentDirectory + "\\EvryNet"))
     {
         EvryNet = await FileFunctions.ByteArrayToObject(File.ReadAllBytes(Environment.CurrentDirectory + "\\EvryNet"));
     }
     EvryFolder.Add(new FolderModel("\\Nets", true));
 }
Exemple #10
0
        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            Menu = new TreeMenu();

            this.Text            = string.Concat(this.Text, " v.", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            _CurrentFullFileName = FileFunctions.OpenFileDialog_New(Menu.GetXml(), FileFunctions.OpenFilterEnums.OpenXmlFilter, true);

            LoadMenuFile();
        }
Exemple #11
0
        public void CanCallExcelTestMacro()
        {
            //Created Macro Test1 in "C:\temp\FSITestFileXLS.xlsm"
            //See https://social.msdn.microsoft.com/Forums/lync/en-US/2e33b8e5-c9fd-42a1-8d67-3d61d2cedc1c/how-to-call-excel-macros-programmatically-in-c?forum=exceldev
            FileFunctions fileFunctions = new FileFunctions();
            string        macroName     = "Test1";

            Assert.IsTrue(fileFunctions.RunExcelMacro(Global.testLocation, Global.fSITest_XLSM, macroName, true));
        }
Exemple #12
0
        /// <summary>
        /// Obtiene un men� de un archivo pasado por parametros y lo dibuja en el control.
        /// </summary>
        /// <param name="menuFilePath">Archivo del cual obtener el men�</param>
        public void LoadFromFile(string pMenuFilePath)
        {
            if (string.IsNullOrEmpty(pMenuFilePath))
            {
                return;
            }

            _MenuBar = MenuNavBar.GetFromXml <MenuNavBar>(FileFunctions.OpenTextFile(pMenuFilePath));

            DrawMenuNavBar();
        }
Exemple #13
0
        /// <summary>
        /// Obtiene un menú de un archivo pasado por parametros
        /// y lo dibuja en el control.
        /// </summary>
        /// <param name="menuFilePath">Archivo del cual obtener el menú</param>
        public void LoadToolBarFromFile(string menuFilePath)
        {
            if (string.IsNullOrEmpty(menuFilePath))
            {
                return;
            }

            _Buttons = ToolBar.GetFromXml <ToolBar>(FileFunctions.OpenTextFile(menuFilePath)); //Fwk.UI.Controls.Menu.Helper.LoadToolBarFromFile(menuFilePath);

            DrawToolBar();
        }
Exemple #14
0
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            _CurrentFullFileName = FileFunctions.OpenFileDialog_Open(FileFunctions.OpenFilterEnums.OpenXmlFilter);

            if (String.IsNullOrEmpty(_CurrentFullFileName))
            {
                return;
            }

            LoadMenuFile();
        }
Exemple #15
0
        private void FillrepLogos()
        {
            string pathTemplate;

            pathTemplate = ConfigSettings.DataStoragePath + "\\logos";
            FileFunctions.CheckDir(pathTemplate, true);
            DirectoryInfo dirInfo = new DirectoryInfo(pathTemplate);

            repLogos.DataSource = dirInfo.GetFiles();
            repLogos.DataBind();
        }
Exemple #16
0
 private void mnuSave_Click(object sender, EventArgs e)
 {
     try
     {
         FileFunctions.OpenFileDialog_New(_IEntity.GetType().Name, _IEntity.GetXml(), FileFunctions.OpenFilterEnums.OpenXmlFilter, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #17
0
        protected static string GetRomCodeFromFile(string filename)
        {
            var fis = new FileStream(filename, FileMode.Open, FileAccess.Read);

            fis.Seek(0x0C, SeekOrigin.Current);
            var sig = FileFunctions.ReadFullyIntoBuffer(fis, 4);

            fis.Close();
            var ndsCode = Encoding.ASCII.GetString(sig, 0, sig.Length);

            return(ndsCode);
        }
Exemple #18
0
        public void CanOpenSiteLists_xlsx()
        {
            FileFunctions filefunctions = new FileFunctions();
            Workbook      workBook      = filefunctions.OpenExcelWorkBook(Path.Combine(Global.testLocation, Global.siteLists_xlxs));

            Assert.IsTrue(workBook.GetType().ToString() == "Microsoft.Office.Interop.Excel.WorkbookClass");
            if (workBook != null)
            {
                //workBook.Close();
                workBook.Application.Quit();
            }
        }
Exemple #19
0
        private void btnViewErrorLog_Click(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(Setting.GetErrorLogFullPath(Properties.Settings.Default.Portable, Setting.getSettingsFullPath(Properties.Settings.Default.Portable))))
            {
                // Do Nothing
            }
            else
            {
                FileFunctions.CreateEmptyFile(Setting.GetErrorLogFullPath(Properties.Settings.Default.Portable, Setting.getSettingsFullPath(Properties.Settings.Default.Portable)));
            }

            System.Diagnostics.Process.Start(Setting.GetErrorLogFullPath(Properties.Settings.Default.Portable, Setting.getSettingsFullPath(Properties.Settings.Default.Portable)));
        }
Exemple #20
0
        public static void SaveToolBarToFile(ToolBar pButtons, string pFile)
        {
            if (string.IsNullOrEmpty(pFile))
            {
                return;
            }

            if (pButtons == null)
            {
                return;
            }

            FileFunctions.SaveTextFile(pFile, pButtons.GetXml(), false);
        }
Exemple #21
0
        public static void SaveMenuToFile(MenuNavBar pMenu, string pFile)
        {
            if (string.IsNullOrEmpty(pFile))
            {
                return;
            }

            if (pMenu == null)
            {
                return;
            }

            FileFunctions.SaveTextFile(pFile, pMenu.GetXml(), false);
        }
Exemple #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Login())
            {
                CloseWindow();
            }
            else
            {
                if (!Page.IsPostBack && Request["qid"] != null)
                {
                    btnPrint.Text             = Root.rm.GetString("Esttxt42");
                    chkheader.RepeatColumns   = 4;
                    chkheader.RepeatDirection = RepeatDirection.Horizontal;
                    chkheader.Items.Insert(0, Root.rm.GetString("PDFOff22"));
                    chkheader.Items.Insert(1, Root.rm.GetString("PDFOff20"));
                    chkheader.Items.Insert(2, Root.rm.GetString("PDFOff21"));
                    chkheader.Items.Insert(3, Root.rm.GetString("PDFOff26"));

                    chkheader.Items[0].Selected = true;

                    QuoteId.Text = Request["qid"];
                    DataTable dt;

                    dt = DatabaseConnection.CreateDataset("SELECT COMPANYNAME,ADDRESS+' '+CITY+' '+PROVINCE+' '+ZIPCODE+' '+STATE+' PHONE '+PHONE+' FAX '+FAX+' '+EMAIL AS COMPANYADDRESS  FROM TUSTENA_DATA").Tables[0];
                    CompanyName.Text    = dt.Rows[0]["companyname"].ToString();
                    CompanyAddress.Text = dt.Rows[0]["companyaddress"].ToString();

                    string pathTemplate;
                    pathTemplate = ConfigSettings.DataStoragePath + "\\logos";
                    FileFunctions.CheckDir(pathTemplate, true);
                    DirectoryInfo dirInfo = new DirectoryInfo(pathTemplate);

                    FileInfo[] files = dirInfo.GetFiles();
                    if (files.Length > 0)
                    {
                        chkLogo.RepeatColumns   = 4;
                        chkLogo.RepeatDirection = RepeatDirection.Horizontal;
                        foreach (FileInfo f in files)
                        {
                            chkLogo.Items.Add(f.Name);
                        }
                        chkLogo.Items[0].Selected = true;
                    }
                }
                else
                {
                    CloseWindow();
                }
            }
        }
Exemple #23
0
 internal static void HandleRename()
 {
     if (FileFunctions.RenameFile(Pics[FolderIndex], ConfigureWindows.GetMainWindow.TitleText.Text))
     {
         Pics[FolderIndex] = ConfigureWindows.GetMainWindow.TitleText.Text;
         Refocus();
         Error_Handling.Reload(); // TODO proper renaming of window title, tooltip, etc.
     }
     else
     {
         Tooltip.ShowTooltipMessage(Application.Current.Resources["AnErrorOccuredMovingFile"]);
         Refocus();
     }
 }
Exemple #24
0
        public void CanPassValueToMacro()
        {
            FileFunctions filefunctions = new FileFunctions();

            string macroName = "Test2MacroWithParameter";
            string passValue = "zishan";

            //Macro "Test2MacroWithParameter" writes to Cell C1.
            filefunctions.PasValueToMacro(Global.testLocation, Global.fSITest_XLSM, macroName, passValue);

            string cellValue = filefunctions.GetCellValue(Global.testLocation, Global.fSITest_XLSM, "Sheet1", "C1");

            Assert.AreEqual(passValue, cellValue);
        }
Exemple #25
0
        public void CanSetActiveCellValue()
        {
            FileFunctions filefunctions = new FileFunctions();

            Workbook  xlWorkBook = filefunctions.OpenExcelWorkBook(Path.Combine(Global.testLocation, Global.fSITest_XLSM));
            Worksheet workSheet  = xlWorkBook.Sheets["Sheet1"] as Worksheet;

            filefunctions.SetActiveCell(workSheet, "A", "2");
            string activeCellValue = filefunctions.GetActiveCellValue(workSheet.Application);

            Assert.AreEqual("This is the Active Cell", activeCellValue);
            xlWorkBook.Close();
            xlWorkBook.Application.Quit();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dtEw;

            dtEw = DatabaseConnection.CreateDataset("SELECT ID FROM TUSTENA_DATA").Tables[0];
            DatabaseConnection.DoCommand("DELETE FROM FOLDERSIZE");
            foreach (DataRow dr in dtEw.Rows)
            {
                try
                {
                    FileFunctions.CheckDir(Path.Combine(ConfigSettings.DataStoragePath, dr[0].ToString() + Path.DirectorySeparatorChar + "template"), true);
                    long size = FileFunctions.FolderSize(ConfigSettings.DataStoragePath + Path.DirectorySeparatorChar + dr[0].ToString() + Path.DirectorySeparatorChar);
                    DatabaseConnection.DoCommand(String.Format("INSERT INTO FOLDERSIZE (FOLDERSIZE) VALUES ({0})", size));
                }catch {}
            }
        }
Exemple #27
0
        public ActionResult UploadFiles()

        {
            // Checking no of files injected in Request object
            if (Request.Files.Count > 0)
            {
                try
                {
                    var fileIds = new List <int>();
                    //  Get all files from Request object
                    var files = Request.Files;
                    for (var i = 0; i < files.Count; i++)
                    {
                        var file = Request.Files[0];

                        if (file == null || file.ContentLength <= 0)
                        {
                            continue;
                        }
                        // Code to process image, resize, etc goes here
                        var image = new DAL.Entities.File
                        {
                            FileName        = file.FileName,
                            FileContentType = file.ContentType,
                            FileBytes       = new byte[file.ContentLength],
                            FileSize        = file.ContentLength
                        };

                        file.InputStream.Read(image.FileBytes, 0, image.FileSize);
                        //add the id to the userProfileDto

                        fileIds.Add(FileFunctions.Create(image));
                    }
                    // Returns message that successfully uploaded
                    return(Json(fileIds.ToArray()));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }
Exemple #28
0
        public static void SaveJpeg(this Image image, string path, int quality = 100)
        {
            var qualityParam  = new EncoderParameter(Encoder.Quality, quality);
            var codec         = ImageCodecInfo.GetImageEncoders()[1];
            var encoderParams = new EncoderParameters(1);

            encoderParams.Param[0] = qualityParam;

            using (var stream = new MemoryStream()) {
                image.Save(stream, codec, encoderParams);
                var bytes = stream.ToArray();

                Directory.CreateDirectory(FileFunctions.GetDirectory(path));
                using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
                    fileStream.Write(bytes, 0, bytes.Length);
            }
        }
Exemple #29
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var writeData = new List <PlayerSaveFile>();

            var playerOffset = Config.PlayerStartOffset;

            writeData.Add(new PlayerSaveFile
            {
                Offset = Config.PlayerNewOffset,
                Length = 1,
                String = "1"
            });

            writeData.Add(new PlayerSaveFile
            {
                Offset = playerOffset,
                Length = Config.PlayerNameMaxLength,
                String = tbPlayerName.Text
            });

            var i = 0;

            foreach (var macro in TextBoxDict)
            {
                var macroOffset = Config.PlayerMacroOffset + (Config.PlayerMacroNextOffset * i);

                writeData.Add(new PlayerSaveFile
                {
                    Offset = macroOffset,
                    Length = Config.PlayerMacroMaxLength,
                    String = macro.Value.Text
                });

                i++;
            }

            var result = FileFunctions.WriteToSaveFile(Path.Combine(LoadedGamePath, Config.PlayerFiles[LoadedPlayer.Index]), writeData);

            if (!result.Success)
            {
                MessageBox.Show(result.ErrorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            btnClose_Click(null, null);
        }
Exemple #30
0
        private void LoadSettingData()
        {
            var result = FileFunctions.ReadConnectionData();

            if (result.Success)
            {
                txt_server.Text   = result.Data.Server;
                txt_database.Text = result.Data.Database;
                txt_user.Text     = result.Data.User;
                txt_password.Text = result.Data.Password;
            }
            else
            {
                lbl_Message.ForeColor = Color.Maroon;
                lbl_Message.Text      = result.Message;
            }
        }