Beispiel #1
0
        public List <string> ExtractRecordsfromGoogelSpreadsheet()
        {
            //var path = HttpContext.Current.Server.MapPath("~/medilabdiscount-97c500b563df.json");
            //var credential = GoogleCredential.FromStream(new FileStream(path, FileMode.Open)).CreateScoped(_scopes);
            //var service = new SheetsService(new BaseClientService.Initializer()
            //{
            //    HttpClientInitializer = credential,
            //    ApplicationName = _applicationName,
            //});

            //String range = "AuthorizedUsers";
            //SpreadsheetsResource.ValuesResource.GetRequest request =
            //                        service.Spreadsheets.Values.Get(spreadsheetId, range);

            String _sheetName = "AuthorizedUsers";
            var    gsh        = new GoogleSheetsHelper();
            var    gsp        = new GoogleSheetParameters()
            {
                RangeColumnStart = 1, RangeRowStart = 1, RangeColumnEnd = 2, RangeRowEnd = 100, FirstRowIsHeaders = true, SheetName = _sheetName
            };
            var rowValues = gsh.GetUserEmailsFromSheet(gsp);

            //List<IDictionary<String, object>> dictionary_object = gsh.GetDataFromSheet(gsp).ToList<ExpandoObject>();
            //ValueRange response = request.Execute();

            //IList<IList<Object>> values = response.Values;

            return(rowValues);
        }
Beispiel #2
0
        public ActionResult Index()
        {
            ViewBag.Message = string.Empty;

            DiscountTransaction transaction = new DiscountTransaction();

            var google = new GoogleSheetsHelper();

            Session["templates"] = google.ReadSMSTemplates(true);

            Session["reasons"] = google.ReadDiscontReasons(true);

            Session["names"] = google.ReadPCCNames(true);

            //Session["enabletimer"] = false;

            ViewData["SMSTemplates"] = Transform(Session["templates"] as IList <string>);

            ViewData["DiscountReasons"] = Transform(Session["reasons"] as IList <string>);

            ViewData["PCCNames"] = Transform(Session["names"] as IList <string>);

            transaction.MessageTemplate = Transform(Session["templates"] as IList <string>).FirstOrDefault().Text;

            return(View(transaction));
        }
Beispiel #3
0
    private static void GeneratePlayableCards(GoogleSheetsHelper gsh)
    {
        Console.WriteLine("-------------------- Generating Playable Cards --------------------");

        List <Card> cards = new List <Card>();
        var         gsp   = new GoogleSheetParameters()
        {
            RangeColumnStart = 1, RangeRowStart = 1, RangeColumnEnd = 7, RangeRowEnd = 1000, FirstRowIsHeaders = true, SheetName = "Cards"
        };
        List <ExpandoObject> rowValues = gsh.GetDataFromSheet(gsp);

        foreach (ExpandoObject row in rowValues) // row ist eine Liste von KeyValuePairs. Diese enthalten als Key den Namen der Spalte (zB "Angriff") und als Value den Wert (zB "7")
        {
            dynamic card       = (dynamic)row;
            string  cardName   = (string)card.Name;
            string  cardText   = (string)card.Text;
            bool    hasPicture = File.Exists(SourcePath + "Images/" + FileNameForCard(cardName));

            if (!hasPicture)
            {
                Console.WriteLine("ERROR: Picture not found for " + cardName + ".");
            }

            if (CreateCardsWithoutImages || hasPicture)
            {
                switch (card.Type)
                {
                case "Kreatur":
                    int  cost   = card.Cost == "X" ? 0 : int.Parse(card.Cost);
                    bool costX  = card.Cost == "X";
                    int  attack = int.Parse(card.Attack);
                    int  health = int.Parse(card.Health);
                    cards.Add(new Creature(cardName, cost, attack, health, card.Class, cardText, costX));
                    break;

                case "Zauber":
                    cost  = card.Cost == "X" ? 0 : int.Parse(card.Cost);
                    costX = card.Cost == "X";
                    cards.Add(new Spell(cardName, cost, cardText, costX));
                    break;

                default:
                    Console.WriteLine("ERROR: " + card.Name + " has unknown type " + card.Type);
                    break;
                }
            }
        }

        foreach (Card c in cards)
        {
            Console.WriteLine("Generating image for " + c.Name);
            CardImageGenerator.GenerateImage(c, SourcePath + "Generated/");
        }

        Console.WriteLine("\n\n");

        Console.WriteLine("Successfully generated " + cards.Count + " playable cards.\n\n");
    }
Beispiel #4
0
        public ApiResponse <object> AddOrderToGoogleSheets(OrderToRecord GoogleSheetOrder)
        {
            ApiResponse <object> result = new ApiResponse <object>();

            var gsh = new GoogleSheetsHelper(); // Initialize Google Sheets Helper

            gsh.CreateEntry(GoogleSheetOrder);  // Create New google sheet row record
            result.Succeeded = true;
            return(result);
        }
Beispiel #5
0
    static void Main(string[] args)
    {
        var gsh = new GoogleSheetsHelper("auth.json", "1YnicTqSHrWr7J6YLfHImQd5V2ygZjRPkzh3CkdpW3e4");

        GeneratePlayableCards(gsh);
        GenerateWeatherCards(gsh);

        Console.WriteLine("Press any key to close the window.");
        Console.ReadKey();
    }
Beispiel #6
0
        public ActionResult About()
        {
            var google = new GoogleSheetsHelper();

            var transactions = google.ReadTransactions(true);

            ViewBag.ExportPermission = ((UserModel)Session["UserModel"]) != null?(bool)((UserModel)Session["UserModel"]).Role.ToString().Equals("ADMINUSER", StringComparison.InvariantCultureIgnoreCase):false;

            Session["ReportsList"] = (transactions != null && transactions.Count >= 0) ? transactions as List <DiscountTransaction> : new List <DiscountTransaction>();

            return(View(CreateExportableGrid(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["GridPageCount"]))));
        }
        private IList <UserModel> GetRegisteredUsers()
        {
            //String _sheetName = System.Configuration.ConfigurationManager.AppSettings["UsersSheetName"];

            var gsh = new GoogleSheetsHelper();

            //var gsp = new GoogleSheetParameters() { RangeColumnStart = 1, RangeRowStart = 1, RangeColumnEnd = 3, RangeRowEnd = 1000, FirstRowIsHeaders = true, SheetName = _sheetName };

            IList <UserModel> rowValues = gsh.ReadUsersList(true);

            return(rowValues);
        }
Beispiel #8
0
        public ActionResult ValidateOTP(string otp)
        {
            var google = new GoogleSheetsHelper();

            var model = Session["transaction"] as DiscountTransaction;

            ViewData["SMSTemplates"] = Transform(Session["templates"] as IList <string>);

            ViewData["DiscountReasons"] = Transform(Session["reasons"] as IList <string>);

            ViewData["PCCNames"] = Transform(Session["names"] as IList <string>);

            if (otp.Length == 4)
            {
                MSGWowHelper helper = new MSGWowHelper();

                var isOTPSent = helper.verifyOTP(otp, model.MobileNumber);

                //var isOTPSent = true;

                if (isOTPSent)
                {
                    model.ValidationStatus = System.Configuration.ConfigurationManager.AppSettings["OTPVerifiedMsg"];

                    model.OTP = otp;

                    google.UpdateValidationStatus(model);

                    ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["SuccessfulTransactionMsg"];

                    Session["transaction"] = model;
                }
                else
                {
                    ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["InvalidOTPMsg"];;

                    //Session["enabletimer"] = true;

                    return(View("Index", model));
                }

                return(View("Transaction", model));
            }
            else
            {
                ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["ProvideOTPMsg"];

                return(View("Index", model));
            }
        }
Beispiel #9
0
        public IList <DiscountTransaction> readGooglesheetvalues()
        {
            var google = new GoogleSheetsHelper();

            IList <DiscountTransaction> transactions = google.ReadTransactions(true);

            if (transactions.Count >= 0)
            {
                return(transactions);
            }
            else
            {
                return(null);
            }
        }
Beispiel #10
0
        //[HttpPost]
        public ActionResult ResendOTP()
        {
            MSGWowHelper helper = new MSGWowHelper();

            var google = new GoogleSheetsHelper();

            var model = Session["transaction"] as DiscountTransaction;

            if (model != null)
            {
                ViewData["SMSTemplates"] = Transform(Session["templates"] as IList <string>);

                ViewData["DiscountReasons"] = Transform(Session["reasons"] as IList <string>);

                ViewData["PCCNames"] = Transform(Session["names"] as IList <string>);

                var messageTempalte = model.MessageTemplate.
                                      Replace(System.Configuration.ConfigurationManager.AppSettings["Customername"], model.CustomerName)
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Discount"], model.Discount.ToString() + " ")
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Discountreason"], model.DiscountReason)
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Billvalue"], model.BillValue.ToString());


                var isOTPSent = helper.resendOTP(model.MobileNumber, messageTempalte);

                if (isOTPSent)
                {
                    ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["SuccessfulOTPMsg"];

                    model.enableValidatebtn = true;

                    // model.enableResendbtn = false;
                }
                else
                {
                    ViewBag.Message         = System.Configuration.ConfigurationManager.AppSettings["FailureOTPMsg"];;
                    model.enableValidatebtn = false;
                    // model.enableResendbtn = true;
                }

                Session["transaction"] = model;
            }
            return(View("Index", model));
        }
        public void SaveAs()
        {
            var gsh = new GoogleSheetsHelper(@"..\ini\MyTutorialGsheet-d6d0997cf1ec.json",
                                             "1U72wGk-LojflkxPAWH-rDv2FGc8iIvPiNRGTy7CTB3I/");
            var row1 = new GoogleSheetRow();
            var row2 = new GoogleSheetRow();

            var cell1 = new GoogleSheetCell()
            {
                CellValue = "Header 1", IsBold = true, BackgroundColor = Color.DarkGoldenrod
            };
            var cell2 = new GoogleSheetCell()
            {
                CellValue = "Header 2", BackgroundColor = Color.Cyan
            };

            var cell3 = new GoogleSheetCell()
            {
                CellValue = "Value 1"
            };
            var cell4 = new GoogleSheetCell()
            {
                CellValue = "Value 2"
            };

            row1.Cells.AddRange(new List <GoogleSheetCell>()
            {
                cell1, cell2
            });
            row2.Cells.AddRange(new List <GoogleSheetCell>()
            {
                cell3, cell4
            });

            var rows = new List <GoogleSheetRow>()
            {
                row1, row2
            };

            gsh.AddCells(new GoogleSheetParameters()
            {
                SheetName = "Sheet1", RangeColumnStart = 1, RangeRowStart = 1
            }, rows);
        }
Beispiel #12
0
    private static void GenerateWeatherCards(GoogleSheetsHelper gsh)
    {
        Console.WriteLine("-------------------- Generating Weather Cards --------------------");

        List <Weather> cards = new List <Weather>();
        var            gsp   = new GoogleSheetParameters()
        {
            RangeColumnStart = 1, RangeRowStart = 1, RangeColumnEnd = 2, RangeRowEnd = 1000, FirstRowIsHeaders = true, SheetName = "Weather"
        };
        List <ExpandoObject> rowValues = gsh.GetDataFromSheet(gsp);

        foreach (ExpandoObject row in rowValues) // row ist eine Liste von KeyValuePairs. Diese enthalten als Key den Namen der Spalte (zB "Angriff") und als Value den Wert (zB "7")
        {
            dynamic card       = (dynamic)row;
            string  cardName   = (string)card.Name;
            string  cardText   = (string)card.Text;
            bool    hasPicture = File.Exists(SourcePath + "Images/" + FileNameForCard(cardName));

            if (!hasPicture)
            {
                Console.WriteLine("ERROR: Picture not found for " + cardName + ".");
            }

            if (CreateCardsWithoutImages || hasPicture)
            {
                cards.Add(new Weather(cardName, cardText));
            }
        }

        foreach (Card c in cards)
        {
            Console.WriteLine("Generating image for " + c.Name);
            CardImageGenerator.GenerateImage(c, SourcePath + "Generated/");
        }

        Console.WriteLine("\n\n");

        Console.WriteLine("Successfully generated " + cards.Count + " weather cards.\n\n");
    }
Beispiel #13
0
        public ActionResult Index(DiscountTransaction model)
        {
            ViewData["SMSTemplates"] = Transform(Session["templates"] as IList <string>);

            ViewData["DiscountReasons"] = Transform(Session["reasons"] as IList <string>);

            ViewData["PCCNames"] = Transform(Session["names"] as IList <string>);

            if (ModelState.IsValid && Session["UserEmail"] != null)
            {
                var google = new GoogleSheetsHelper();

                model.UserEmail = Session["UserEmail"].ToString();

                model.ValidationStatus = System.Configuration.ConfigurationManager.AppSettings["OTPVerificationPendingMsg"];

                model.enableSubmitbtn = false;

                MSGWowHelper helper = new MSGWowHelper();

                var messageTempalte = model.MessageTemplate.
                                      Replace(System.Configuration.ConfigurationManager.AppSettings["Customername"], model.CustomerName)
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Discount"], model.Discount.ToString() + " ")
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Discountreason"], model.DiscountReason)
                                      .Replace(System.Configuration.ConfigurationManager.AppSettings["Billvalue"], model.BillValue.ToString());

                model.MessageTemplate = messageTempalte;

                google.CreateTransaction(model);

                var isOTPSent = helper.sendOTP(model.MobileNumber, messageTempalte);

                //var isOTPSent = true;

                if (isOTPSent)
                {
                    ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["SuccessfulOTPMsg"];

                    //Session["enabletimer"] = true;

                    model.enableValidatebtn = true;

                    // model.enableResendbtn = true;

                    Session["transaction"] = model;

                    google.UpdateMsgTemplate(model);


                    return(View(model));
                    //enable validate otp button , disabled resend
                }
                else
                {
                    ViewBag.Message = System.Configuration.ConfigurationManager.AppSettings["FailureOTPMsg"];

                    model.enableValidatebtn = true;  // Final fix

                    // model.enableResendbtn = true;

                    Session["transaction"] = model;

                    //Should we wait for 30 sec or enable resend button ??  -> enable resend button , disabled validate otp btn
                    return(View(model));
                }
            }

            return(View(model));
        }
Beispiel #14
0
 internal static void SaveMsg(string text)
 {
     var gsh = new GoogleSheetsHelper("client_secret.json", "15YK4sgOmEyfKO5EGdbM41ceuRhAOiZpEI-BO1S7oeSo");
 }
 public static IList <IList <Object> > GetGoogleSheet(string spreadsheetId, string sheetRange)
 {
     return(GoogleSheetsHelper.GetGoogleSheetValues(spreadsheetId, sheetRange));
 }
    private void OnGUI()
    {
        GetLocalization();

        var halfwidth = position.width / 2f - 6f;

        serializedObject.Update();

        var englishProp = serializedObject.FindProperty("englishLocals");

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Keys", GUILayout.Width(halfwidth));
        EditorGUILayout.LabelField("Text", GUILayout.Width(halfwidth));
        EditorGUILayout.EndHorizontal();

        page = Mathf.Clamp(page, 0, englishProp.arraySize / 15);

        var h = 0;
        var i = page * heightLimit;

        while (i < englishProp.arraySize && h < heightLimit)
        {
            var element = englishProp.GetArrayElementAtIndex(i);
            var key     = element.FindPropertyRelative("key");
            var text    = element.FindPropertyRelative("text");

            EditorGUILayout.BeginHorizontal();
            key.stringValue  = EditorGUILayout.TextField(key.stringValue, GUILayout.Width(halfwidth));
            text.stringValue = EditorGUILayout.TextField(text.stringValue, GUILayout.Width(halfwidth));
            EditorGUILayout.EndHorizontal();

            i++;
            h++;
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Prev Page"))
        {
            page--;
            GUIUtility.keyboardControl = 0;
        }
        GUILayout.Label(string.Format("{0}-{1}", page * heightLimit, Mathf.Min((page + 1) * heightLimit, englishProp.arraySize)));
        if (GUILayout.Button("Next Page"))
        {
            page++;
            GUIUtility.keyboardControl = 0;
        }
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add key"))
        {
            englishProp.InsertArrayElementAtIndex(englishProp.arraySize);
        }
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(20f);
        if (GUILayout.Button("Push"))
        {
            GoogleSheetsHelper.Push();
        }
        if (GUILayout.Button("Pull"))
        {
            GoogleSheetsHelper.Pull();
        }

        serializedObject.ApplyModifiedProperties();
    }