Ejemplo n.º 1
0
        /// <summary>
        /// Get summary usage for current subscription period. Returns logs for the current subscription period as XLSX workbook.
        /// </summary>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\logFile.xlsx</param>
        public void GetSummaryUsageForCurrentSubscriptionPeriod(string outputPath)
        {
            // GET  usage/summary?appSID={appSID}

            string apiUrl = "usage/currentPeriod";

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = System.IO.File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get users with plans statistics.
        /// </summary>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\stats.html</param>
        public void GetUsersWithPlansStatistics(string outputPath)
        {
            // GET  statistics/plans?appSID={appSID}

            string apiUrl = "statistics/plans?";

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get usage logs for some period. Returns logs for the period required as XLSX workbook.
        /// </summary>
        /// <param name="start">Start date and time for logs generated.</param>
        /// <param name="end">End date and time for logs generated.</param>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\logFile.xlsx</param>
        public void GetUsageLogsForSomePeriod(DateTime start, DateTime end, string outputPath)
        {
            //	GET  usage?start={start}&end={end}&appSID={appSID}

            string apiUrl = string.Format(@"usage?start={0}&end={1}", start, end);

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = System.IO.File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get service statistics in HTML form like GroupDocs.
        /// </summary>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\stats.html</param>
        public void GetServiceStatisticsInHTMLFormLikeGroupDocs(string outputPath)
        {
            // GET  statistics/likeGD?appSID={appSID}

            string apiUrl = "statistics/likeGD?";

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get statistics for last 30 days by hours.
        /// </summary>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\stats.html</param>
        public void GetStatisticsForLast30DaysByHours(string outputPath)
        {
            // GET  statistics/hours/last30Days?appSID={appSID}

            string apiUrl = "statistics/hours/last30Days?";

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get statistics for specific dates by hours.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="outputPath">Local path where the log file will be saved e.g c:\stats.html</param>
        public void GetStatisticsForSpecificDatesByHours(DateTime startDate, DateTime endDate, string outputPath)
        {
            // GET  statistics/hours?startDate={startDate}&appSID={appSID}&endDate={endDate}

            string apiUrl = string.Format(@"statistics/hours?startDate={0}&endDate={1}", startDate, endDate);

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(outputPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get email attachment by name.
        /// </summary>
        /// <param name="name">File name. e.g. myEmail.msg</param>
        /// <param name="attachName">Attachment name</param>
        /// <param name="folder">Folder path.</param>
        /// <param name="outPath">Local outpath to save the attachment. e.g. c:\test.doc</param>
        /// <param name="storage">The document storage.</param>
        public void GetEmailAttachmentByName(string name, string attachName, string folder, string outPath, string storage = "")
        {
            // GET  email/{name}/attachments/{attachName}?appSid={appSid}&storage={storage}&folder={folder}

            string apiUrl = string.Format(@"email/{0}/attachments/{1}?storage={2}&folder={3}",
                                          name, attachName, storage, folder);

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(outPath))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Generate barcode, the generated barcode image will be saved on provided disk location
        /// </summary>
        /// <param name="text">The code text</param>
        /// <param name="type">Barcode type</param>
        /// <param name="format">Result format</param>
        /// <param name="enableChecksum">Sets if checksum will be generated</param>
        /// <param name="localPathWithFileNameAndExtension">Local disk path with filename and extension to save the generated barcode image. It will overwrite the file if it already exists</param>
        /// <param name="resolutionX">Horizontal resolution in DPI. Default is 96</param>
        /// <param name="resolutionY">Vertical resolution in DPI. Default is 96</param>
        /// <param name="dimensionX">Smallest width of barcode unit (bar or space). Default is 0.7</param>
        /// <param name="dimensionY">Smallest height of barcode unit (for 2D barcodes). Default is 2</param>
        public void GenerateBarCode(string text, BarCodeType type, BarCodeImageFormat format, string localPathWithFileNameAndExtension,
                                    EnableChecksum enableChecksum = EnableChecksum.No, float resolutionX = 96, float resolutionY = 96, double dimensionX = 0.7, float dimensionY = 2)
        {
            // GET barcode/generate?appSid={appSid}&text={text}&type={type}&format={format}&resolutionX={resolutionX}
            //                                &resolutionY={resolutionY}&dimensionX={dimensionX}&dimensionY={dimensionY}&enableChecksum={enableChecksum}

            string apiUrl = string.Format(@"barcode/generate?text={0}&type={1}&format={2}&resolutionX={3}&resolutionY={4}&dimensionX={5}&dimensionY={6}&enableChecksum={7}",
                                          text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, enableChecksum);

            using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                using (Stream file = File.OpenWrite(localPathWithFileNameAndExtension))
                {
                    ServiceController.CopyStream(responseStream, file);
                }
        }
Ejemplo n.º 9
0
            /// <summary>
            /// Download a specific file.
            /// </summary>
            /// <param name="path">file path to download e.g. /file.ext</param>
            /// <param name="versionID">file's version</param>
            /// <param name="destinationFilePath">Local destination path to save the downloaded file</param>
            /// <param name="storage">user's storage name</param>
            public void DownloadFile(string path, string destinationPath, int versionID = 0, string storage = "")
            {
                // GET  storage/file/{path}?appSID={appSID}&versionID={versionID}&storage={storage}

                string apiUrl = string.Format(@"storage/file/{0}?storage={1}", path, storage);

                if (!string.IsNullOrEmpty(storage))
                {
                    apiUrl = apiUrl + string.Format("&versionID={0}", versionID);
                }

                if (!string.IsNullOrEmpty(destinationPath) && Directory.Exists(Path.GetDirectoryName(destinationPath)))
                {
                    using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                        using (Stream file = System.IO.File.OpenWrite(destinationPath))
                        {
                            ServiceController.CopyStream(responseStream, file);
                        }
                }
            }
Ejemplo n.º 10
0
        /// <summary>
        /// Convert mail message to target format
        /// </summary>
        /// <param name="name">File name. e.g. myEmail.msg</param>
        /// <param name="format">Email format. e.g Eml, Msg, Mht</param>
        /// <param name="folder">Folder path.</param>
        /// <param name="outPath">Path to save result. It can be a local path e.g c:\file.eml or cloud storage path e.g. MyFolder/file.eml</param>
        /// <param name="storage">The document storage.</param>
        public void ConvertMailMessageToTargetFormat(string name, EmailFormat format, string folder, string outPath, string storage = "")
        {
            // GET  email/{name}?appSid={appSid}&format={format}&storage={storage}&folder={folder}&outPath={outPath}

            string apiUrl = string.Format(@"email/{0}?format={1}&storage={2}&folder={3}&outPath={4}",
                                          name, format, storage, folder, (outPath.Contains(@":\") ? string.Empty : outPath));

            if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath)))
            {
                using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey))
                    using (Stream file = File.OpenWrite(outPath))
                    {
                        ServiceController.CopyStream(responseStream, file);
                    }
            }
            else
            {
                ServiceController.Get(apiUrl, AppSid, AppKey);
            }
        }