Пример #1
0
        public async Task <FileExportModel> GetExportFileStream(string fileType)
        {
            MemoryStream fs       = null;
            string       fileName = "SampleFile";

            switch (fileType.ToUpper())
            {
            case "PDF":
                fs = new MemoryStream(ExportHelpers.GetPdfStream());
                break;

            case "XLS":
                fs = new MemoryStream();
                break;

            case "XLSX":
                fs = new MemoryStream();
                break;

            case "CSV":
                fs = new MemoryStream();
                break;

            default:
                fs = new MemoryStream();
                break;
            }

            return(new FileExportModel {
                FileName = fileName,
                stream = fs
            });
        }
Пример #2
0
        public void ExportGameObjects_SceneClosedAfterExport()
        {
            var filePath = CreateTmpUsdFile("dummyUsd.usda");
            var scene    = Scene.Open(filePath);

            ExportHelpers.ExportGameObjects(new [] { new GameObject("test") }, scene, BasisTransformation.SlowAndSafe);
            Assert.IsNull(scene.Stage);
        }
Пример #3
0
        public void ExportGameObjects_InvalidGO()
        {
            var filePath = CreateTmpUsdFile("dummyUsd.usda");
            var scene    = Scene.Open(filePath);

            Assert.DoesNotThrow(delegate()
            {
                ExportHelpers.ExportGameObjects(new GameObject[] { null }, scene, BasisTransformation.SlowAndSafe);
            });
            UnityEngine.TestTools.LogAssert.Expect(LogType.Exception, "NullReferenceException: Object reference not set to an instance of an object");
        }
Пример #4
0
        public void InitForSave_ValidPath()
        {
            var filePath = System.IO.Path.Combine(Application.dataPath, "dummyUsd.usd");

            m_filesToDelete.Add(filePath);
            var scene = ExportHelpers.InitForSave(filePath);

            Assert.IsNotNull(scene);
            Assert.IsNotNull(scene.Stage);
            scene.Close();
        }
Пример #5
0
        public void ExportGameObjects_ValidGO()
        {
            var filePath = CreateTmpUsdFile("dummyUsd.usda");
            var scene    = Scene.Open(filePath);

            ExportHelpers.ExportGameObjects(new [] { new GameObject("test") }, scene, BasisTransformation.SlowAndSafe);
            scene = Scene.Open(filePath);
            var paths = scene.Stage.GetAllPaths();

            Debug.Log(scene.Stage.GetRootLayer().ExportToString());
            Assert.AreEqual(2, paths.Count);
            scene.Close();
        }
        private void buttonExportExcel_Click(object sender, EventArgs e)
        {
            var dt = SqlHelpers.GetDataTable(CBuilder.QueryTransformer.ResultAST.GetSQL(SqlGenerationOptions), SqlQuery);

            var saveDialog = new SaveFileDialog {
                AddExtension = true, DefaultExt = "xlsx", FileName = "Export.xlsx"
            };

            if (saveDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            ExportHelpers.ExportToExcel(dt, saveDialog.FileName);
        }
Пример #7
0
        public void ExportGameObjects_EmptyList()
        {
            var filePath       = CreateTmpUsdFile("dummyUsd.usda");
            var scene          = Scene.Open(filePath);
            var fileInfoBefore = new FileInfo(filePath);

            Assert.DoesNotThrow(delegate()
            {
                ExportHelpers.ExportGameObjects(new GameObject [] {}, scene, BasisTransformation.SlowAndSafe);
            });
            var fileInfoAfter = new FileInfo(filePath);

            Assert.AreEqual(fileInfoBefore.Length, fileInfoAfter.Length);
            scene.Close();
        }
        private void buttonExportCsv_Click(object sender, EventArgs e)
        {
            var saveDialog = new SaveFileDialog {
                AddExtension = true, DefaultExt = "csv", FileName = "Data.csv"
            };
            var result = saveDialog.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            var dt = SqlHelpers.GetDataTable(CBuilder.QueryTransformer.ResultAST.GetSQL(SqlGenerationOptions), SqlQuery);

            ExportHelpers.ExportToCSV(dt, saveDialog.FileName);
        }
Пример #9
0
        protected override void SessionCreated(RecordingSession session)
        {
            base.SessionCreated(session);

            InitUsd.Initialize();
            var outputFile = Settings.FileNameGenerator.BuildAbsolutePath(session);

            if (Settings.ExportFormat == UsdRecorderSettings.Format.USDZ) // FIXME Support USDz
            {
                try
                {
                    currentDir = Directory.GetCurrentDirectory();
                    // Setup a temporary directory to export the wanted USD file and zip it.
                    var tmpDirPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
                    usdzTemporaryDir = Directory.CreateDirectory(tmpDirPath);

                    // Get the usd file name to export and the usdz file name of the archive.
                    usdcFileName = Path.GetFileNameWithoutExtension(outputFile) + ".usdc";
                    usdzFileName = Path.GetFileName(outputFile);
                    var fi = new FileInfo(outputFile);
                    usdzFilePath = fi.FullName;

                    // Set the current working directory to the tmp directory to export with relative paths.
                    Directory.SetCurrentDirectory(tmpDirPath);

                    outputFile = Path.Combine(tmpDirPath, usdcFileName);
                }
                finally
                {
                    Directory.SetCurrentDirectory(currentDir);
                }
            }

            try
            {
                context = new ExportContext
                {
                    scene = ExportHelpers.InitForSave(outputFile)
                };
            }
            catch (Exception)
            {
                throw new InvalidOperationException($"The file is already open in Unity. Please close all references to it and try again: {outputFile}");
            }


            context.scene.FrameRate = Settings.FrameRate;                         // Variable framerate support ?
            context.scene.Stage.SetInterpolationType(Settings.InterpolationType); // User Option

            context.basisTransform  = Settings.BasisTransformation;
            context.activePolicy    = Settings.ActivePolicy;
            context.exportMaterials = Settings.ExportMaterials;

            context.scale = Settings.Scale;

            context.scene.StartTime = 0; // Absolute vs relative Time

            // Export the "default" frame, that is, all data which doesn't vary over time.
            context.scene.Time = null;

            Input.Context = context;
        }
Пример #10
0
        static void Main(string[] args)
        {
            if (args.Count() > 0)
            {
                if (args[0] == "ship")
                {
                    #region Mark As Shipped
                    try
                    {
                        //This is a fix for it being a desktop application.  This should not
                        //be run on a live webserver
                        ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

                        //Use app.config so the directory can be changed regardless of the code
                        string dir = ConfigurationManager.AppSettings["ShippingData"].ToString();

                        //grab all the files in the directory
                        Directory.GetFiles(dir);
                        foreach (var file in Directory.GetFiles(dir))
                        {
                            //Get just the name of the file
                            FileInfo import   = new FileInfo(file);
                            string   filename = import.Name.Split('.')[0];

                            //Split on '_' and it should create a array with the length of 3
                            string[] filenamesplit = filename.Split('_');
                            if (filenamesplit.Length == 4)
                            {
                                string consumerKey    = filenamesplit[0];
                                string consumerSecret = filenamesplit[1];

                                var client = new RestClient();
                                client.BaseUrl       = APIHelper.GetBaseUri();
                                client.Authenticator = new HttpBasicAuthenticator(consumerKey, consumerSecret);

                                var summaries = ImportHelper.ImportShippingSummaries(file);


                                if (summaries.FirstOrDefault() != null && summaries.FirstOrDefault().Company_ID != "-1")
                                {
                                    //changed to false if any of the orders fail to be posted.
                                    bool allShipped = true;
                                    foreach (var summary in summaries)
                                    {
                                        //Use the summary information to create a JSON object
                                        string order = OrderServices.GetOrderByOrderNumber(client, summary);

                                        //if the string did not return and error try to
                                        //do a post.
                                        if (!order.StartsWith("An Error Has Occured"))
                                        {
                                            //Shipsation async code, but it causes business logic problems
                                            //Task tsk = OrderServices.MakeAsyncOrderPost(order, consumerKey, consumerSecret);
                                            //tsk.Wait();

                                            //Post the order to be marked.
                                            allShipped = OrderServices.MarkOrderPost(client, order);
                                        }
                                        else
                                        {
                                            allShipped = false;
                                        }
                                    }

                                    if (allShipped)
                                    {
                                        // File.Delete(file);
                                        //Update first row companyID to -1
                                        string DSN = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", file);
                                        using (System.Data.OleDb.OleDbConnection Con = new System.Data.OleDb.OleDbConnection(DSN))
                                        {
                                            Con.Open();
                                            using (System.Data.OleDb.OleDbCommand Com = new System.Data.OleDb.OleDbCommand())
                                            {
                                                Com.Connection  = Con;
                                                Com.CommandText = "UPDATE [Shipping_Summary___Optional_Sav$] SET [Company_ID] = -1 WHERE [Company_ID] = " + summaries.FirstOrDefault().Company_ID;
                                                Com.ExecuteNonQuery();
                                            }
                                            Con.Close();
                                        }
                                    }
                                    else
                                    {
                                        MailMessage mail       = new MailMessage();
                                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                                        mail.From = new MailAddress("*****@*****.**");
                                        mail.To.Add("*****@*****.**");
                                        mail.Subject = "An Error Has Occured Posting to Ship Station";
                                        mail.Body    = string.Format("Not all orders for the file {0} were marked as shipped", import.Name);

                                        SmtpServer.Port        = 587;
                                        SmtpServer.Credentials = new NetworkCredential("*****@*****.**", "5HB7c9ut");
                                        SmtpServer.EnableSsl   = true;

                                        SmtpServer.Send(mail);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add("*****@*****.**");
                        mail.Subject = "An Error Has Occured Posting to Ship Station";
                        mail.Body    = string.Format(ex.ToString());

                        SmtpServer.Port        = 587;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "5HB7c9ut");
                        SmtpServer.EnableSsl   = true;

                        SmtpServer.Send(mail);
                    }
                    #endregion
                }

                if (args[0] == "orders")
                {
                    #region Pull Order
                    var customers = ImportHelper.ImportShipstationCustomers();
                    foreach (var customer in customers)
                    {
                        Console.WriteLine("Processing {0}", customer.CompanyName);
                        var client = new RestClient();
                        client.BaseUrl       = APIHelper.GetBaseUri();
                        client.Authenticator = new HttpBasicAuthenticator(customer.Key, customer.Token);


                        //RestRequest request = new RestRequest("users", Method.GET);
                        //IRestResponse response = client.Execute(request);
                        //get all the stores
                        Console.WriteLine("Getting All Stores");
                        List <Store> stores = StoreService.GetAllStores(client);

                        Console.WriteLine("Pulling down unshipped orders");
                        //var orders = OrderServices.GetOrders(client, storeId);
                        List <Order> orders = new List <Order>();
                        foreach (var store in stores)
                        {
                            Console.WriteLine("Pulling down unshipped orders for {0}", store.storeName);
                            orders.AddRange(OrderServices.GetOrders(client, store.storeId));
                        }


                        var SClientorders = orders.Where(o => o.userId == APIHelper.GetShipstationUserID()).ToList();

                        //check to see if the id's have been
                        List <string> extractedids = new List <string>();
                        using (StreamReader reader = new StreamReader(System.Configuration.ConfigurationManager.AppSettings["Path"] + "extractedids.txt"))
                        {
                            string line = reader.ReadLine();
                            while (line != null)
                            {
                                extractedids.Add(line.Trim());
                                line = reader.ReadLine();
                            }

                            reader.Close();
                        }
                        foreach (var id in extractedids)
                        {
                            var order = SClientorders.Where(xo => xo.orderNumber == id).FirstOrDefault();
                            if (order != null)
                            {
                                SClientorders.Remove(order);
                            }
                        }


                        if (SClientorders.Count > 0)
                        {
                            Console.WriteLine("Creating Extraction Report Count : {0}", SClientorders.Count);
                            ExportHelpers.ExtractionReport(SClientorders, customer, stores);

                            Console.WriteLine("Sending Email");
                            MailHelpers.SendEmailWithOrders(customer.CompanyName);
                            Console.WriteLine("Finished Processing {0}", customer.CompanyName);

                            //save the id's
                            using (StreamWriter writer = new StreamWriter(System.Configuration.ConfigurationManager.AppSettings["Path"] + "extractedids.txt", true))
                            {
                                foreach (var order in SClientorders.OrderBy(y => y.orderNumber))
                                {
                                    writer.WriteLine(order.orderNumber);
                                }
                            }
                        }
                        else
                        {
                            MailMessage mail       = new MailMessage();
                            SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                            mail.From = new MailAddress("*****@*****.**");
                            mail.To.Add("[email protected],[email protected]");
                            mail.Bcc.Add("*****@*****.**");
                            mail.Subject = customer.CompanyName + " Orders From Ship Station - No New Orders";
                            mail.Body    = string.Format("No New Orders");

                            SmtpServer.Port        = 587;
                            SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "5HB7c9ut");
                            SmtpServer.EnableSsl   = true;

                            SmtpServer.Send(mail);
                        }
                    }
                    #endregion
                }
                Console.WriteLine("done");
            }
            else
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.Subject = "An Error Has Occured Posting to Ship Station";
                mail.Body    = string.Format("No Argument Has Been Passed");

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "5HB7c9ut");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
            }
        }
Пример #11
0
        public void InitForSave_NullFile()
        {
            var scene = ExportHelpers.InitForSave(null);

            Assert.IsNull(scene);
        }
Пример #12
0
        public void InitForSave_EmptyFile()
        {
            var scene = ExportHelpers.InitForSave("");

            Assert.IsNull(scene);
        }
Пример #13
0
        static void Main(string[] args)
        {
            //Just here for the purposes of alpha prototype stuff
            //UserService US = new UserService();
            //User ushi = US.GetUser(client, "ushi84", true, false);
            const string consumerKey       = "";
            const string consumerSecret    = "";
            const string accessToken       = "";
            const string accessTokenSecret = "";



            var client = new RestClient();

            client.BaseUrl       = AppKeys.GetBaseUri();
            client.Authenticator = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, accessToken, accessTokenSecret);
            ShopService    SS         = new ShopService();
            ListingService LS         = new ListingService();
            UserService    US         = new UserService();
            var            Company    = InternalClientService.GetInternalClientByID("646");
            bool           consoleApp = false;

            if (consoleApp)
            {
                //RestRequest request = new RestRequest("/oauth/scopes", Method.GET);
                //IRestResponse response = client.Execute(request);
                //JObject oq = JObject.Parse(response.Content);
                //Console.WriteLine(oq.ToString());
                var command = Console.ReadLine();
                var user    = US.GetUser(client, "threadedtees", true, false);


                if (command.ToLower() == "getlistings")
                {
                    RestRequest request = new RestRequest();
                    request.Resource = string.Format("/taxonomy/seller/get");
                    IRestResponse response = client.Execute(request);
                    JObject       o        = JObject.Parse(response.Content);
                    Console.WriteLine(o.ToString());

                    LS.ImportListing(client);

                    Authorization.GetAccessToken();

                    var listings = SS.GetShopListings(client, Company.EtsyShopIDs.First());
                    //listring id
                    //title
                    //variation name
                    //variation value

                    ExportHelpers.ExportListingIdAndVariations(user.shops.FirstOrDefault().listings, @"C:\Internal\Etsy\ListingIdAndVariation.txt", true);
                }
                if (command.ToLower() == "createlistings")
                {
                    ListingHelper.CreateEtsyListingFromCustomMapping(client, Company, @"C:\Internal\Etsy\CalculatedFailure_FirstTest_Amazon_Feed.txt");
                }
                #region Listing Tool Code

                #endregion

                if (command.ToLower() == "download")
                {
                    string path = @"C:\Internal\Etsy.txt";

                    var receipts = SS.GetOpenShopReceipts(client, Company.EtsyShopIDs.FirstOrDefault());
                    Console.WriteLine("Exporting...");
                    ExportHelpers.ExtractionExport(receipts, path, CountryService.GetCountryMapping(client), true);
                    Console.Write("Export Complete");
                }

                if (command.ToLower() == "upload")
                {
                    ImportHelpers.ShippingSummaries();
                    Console.Write("Upload Complete");
                    Console.ReadLine();
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new DownloadUploadForm());
            }


            #region Listing Creation Stuff

            #endregion
        }