public DSTRViewerWindow(string envStr, string usrName)
 {
     InitializeComponent();
     this.initialized      = false;
     this.curEnvString     = envStr;
     this.curUserName      = usrName;
     this.selectedStore    = string.Empty;
     this.dateStorageMap   = new Dictionary <long, List <PairType <string, Document> > >();
     this.storeList        = new List <string>();
     this.selectedDate     = DateTime.MinValue;
     this.couchConnector   = null;
     this.selectedDocument = null;
     this.Finished         = false;
 }
        private bool IsDocumentDSTR(string id, out Document doc)
        {
            var rt = false;

            doc = null;
            if (!string.IsNullOrEmpty(id))
            {
                //Fetch document meta-data
                string errMsg;
                if (CouchDbUtils.GetDocument(id, this.couchConnector, out doc, out errMsg, true))
                {
                    if (doc != null && !string.IsNullOrEmpty(doc.FileName) &&
                        doc.FileName.IndexOf("dstr", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        rt = true;
                    }
                }
            }

            return(rt);
        }
        private bool GetShowPrintCouchDocument(string id, Document doc, out string errMsg)
        {
            errMsg = string.Empty;
            if (!string.IsNullOrEmpty(id) && doc != null)
            {
                //Retrieve the document data
                byte[] dataArray;

                if (!doc.GetSourceData(out dataArray))
                {
                    errMsg = "Cannot retrieve document file data with id of " + id;
                    return(false);
                }

                //Write to a file
                try
                {
                    var fStream = new FileStream("curDstr.pdf", FileMode.Create, FileAccess.ReadWrite);
                    fStream.Write(dataArray, 0, dataArray.Length);
                    fStream.Flush();
                    fStream.Close();
                }
                catch (IOException ieX)
                {
                    errMsg = "IOException thrown when trying to write temp file: " + ieX.Message;
                    return(false);
                }

                var procHandle = new Process
                {
                    StartInfo =
                    {
                        WorkingDirectory = Environment.CurrentDirectory,
                        WindowStyle      = ProcessWindowStyle.Normal,
                        CreateNoWindow   = false,
                        FileName         = "curDstr.pdf"
                    }
                };

                try
                {
                    if (procHandle.Start())
                    {
                        procHandle.WaitForExit();
                    }
                    if (!WriteTimeLimit())
                    {
                        errMsg = "Could not update time limiter file";
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    errMsg = "Exception thrown while showing PDF file! Message = " + ex.Message;
                    return(false);
                }
            }
            else
            {
                errMsg = "Could not find document with an ID of " + id;
                return(false);
            }
            return(true);
        }