void SaveCSVLocation(string filename, IGLNLocation iGLNLocation)
        {
            var reader  = new StreamReader(filename);
            var content = reader.ReadToEnd();

            reader.Close();
            char[]   splitParams = new char[] { '\r', '\n' };
            string[] rows        = content.Split(splitParams, StringSplitOptions.RemoveEmptyEntries);

            var newRow = string.Empty;
            var oldRow = string.Empty;

            foreach (string row in rows)
            {
                if (row.Contains(iGLNLocation.GLN))
                {
                    oldRow = row;
                    newRow = Regex.Replace(row, "False", "True", RegexOptions.IgnoreCase);
                    break;
                }
            }

            if (newRow != string.Empty && oldRow != string.Empty)
            {
                content = Regex.Replace(content, oldRow, newRow);
            }

            var writer = new StreamWriter(filename);

            writer.Write(content);
            writer.Close();
        }
 public void SaveLocation(string filename, IGLNLocation iGLNLocation)
 {
     if (filename.Contains(".csv"))
     {
         SaveCSVLocation(filename, iGLNLocation);
     }
     else if (filename.Contains(".xlsx"))
     {
         SaveXLSLocation(filename, iGLNLocation);
     }
 }
        void SaveXLSLocation(string filename, IGLNLocation iGLNLocation)
        {
            var stream = File.Open(filename, FileMode.Open, FileAccess.ReadWrite);
            IExcelDataReader excelReader;

            if (filename.Contains(".xlsx"))
            {
                excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            }
            else
            {
                excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
            }

            stream.Close();

            excelReader.IsFirstRowAsColumnNames = true;
            var dataset = excelReader.AsDataSet();

            var rowCollection = dataset.Tables[0].Rows;

            foreach (DataRow row in rowCollection)
            {
                if (row[11].ToString().Contains(iGLNLocation.GLN))
                {
                    var printed = (string)row[13];
                    printed = Regex.Replace(printed, "False", "True", RegexOptions.IgnoreCase);
                    row[13] = printed;

                    break;
                }
            }

            try
            {
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }

                stream = File.Open(filename, FileMode.Create, FileAccess.ReadWrite);
                using (SpreadsheetDocument document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook))
                    ExcelFunctions.WriteExcelFile(dataset, document);


                stream.Close();
            }
            catch (Exception ex)
            {
                // call LogFile method and pass argument as Exception message, event name, control name, error line number, current form name
                // LogFile(ex.Message + " :6", ex.ToString(), MethodBase.GetCurrentMethod().Name, ExceptionHelper.LineNumber(ex), GetType().Name);
            }
        }
Ejemplo n.º 4
0
        public async void SaveFile(string filename, IGLNLocation location)
        {
            try
            {
                AndHUD.Shared.Show(this, "Updating...", -1, MaskType.Black);
                await Task.Factory.StartNew(() =>
                                            fileUtility.SaveLocation(filename, location));

                AndHUD.Shared.Dismiss(this);
            }
            catch (Exception ex)
            {
                // call LogFile method and pass argument as Exception message, event name, control name, error line number, current form name
                fileUtility.LogFile(ex.Message, ex.ToString(), MethodBase.GetCurrentMethod().Name, ExceptionHelper.LineNumber(ex), GetType().Name);
            }
        }
Ejemplo n.º 5
0
        string GetZplGLNLabel(IGLNLocation location, int position)
        {
            var zpl =
                @"^XA" + "\r\n" +
                @"^MMT" + "\r\n" +
                @"^PW601" + "\r\n" +
                @"^LL0406" + "\r\n" +
                @"^LS0" + "\r\n";

            if (location == null)
            {
                zpl +=
                    @"^BY3,3,230^FT508,109^BCI,,N,N^FD>;>8414" + "1234567890123" + "^FS" + "\r\n" +
                    @"^FT441,71^A0I,34,33^FB276,1,0,C^FH\^FD(414)" + "1234567890123" + "\r\n";
            }
            else
            {
                if (locationList[position].Region == "ROYAL CORNWALL HOSPITALS NHS TRUST")
                {
                    // Royal Cornwall want the room code above the barcode
                    zpl +=
                        @"^FT591,340^A0I,54,52^FD" + "Room Number:" + locationList[position].Code + "^FS" + "\r\n" +
                        @"^BY3,3,230^FT508,89^BCI,,N,N^FD>;>8414" + locationList[position].GLN + "^FS" + "\r\n" +
                        @"^FT441,41^A0I,34,33^FB276,1,0,C^FH\^FD(414)" + locationList[position].GLN + "\r\n";
                    // @"^FT591,360^A0I,40,39^FD" + "Room Number:" + locationList[currentSelected].Code + "^FS" + "\r\n" +
                    // @"^BY3,3,230^FT508,109^BCI,,N,N^FD>;>8414" + locationList[currentSelected].GLN + "^FS" + "\r\n" +
                    // @"^FT441,71^A0I,34,33^FB276,1,0,C^FH\^FD(414)" + locationList[currentSelected].GLN + "\r\n";
                }
                else
                {
                    zpl +=
                        @"^BY3,3,230^FT508,109^BCI,,N,N^FD>;>8414" + locationList[position].GLN + "^FS" + "\r\n" +
                        @"^FT441,71^A0I,34,33^FB276,1,0,C^FH\^FD(414)" + locationList[position].GLN + "\r\n";
                }
            }

            zpl += @"^PQ" + printQuantity + ",0,1,Y^XZ" + "\r\n";
            return(zpl);
        }
Ejemplo n.º 6
0
 void SaveLocations(string filename, IGLNLocation location)
 {
     fileUtility.SaveLocation(filename, location);
 }