public GDataAPI(NameValueCollection parameters)
        {
            try
            {
                SpreadsheetsService service = new SpreadsheetsService("post2spreadsheet");
                service.setUserCredentials(cardeira.Properties.Settings.Default.gUserName, cardeira.Properties.Settings.Default.gPassword);

                Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();

                SpreadsheetFeed feed = service.Query(query);
                SpreadsheetEntry entry = null;
                foreach (SpreadsheetEntry e in feed.Entries)
                {
                    entry = e;
                    logger.Debug("Spreadsheet: {0}", entry.Title.Text);
                    if (entry.Title.Text == cardeira.Properties.Settings.Default.spreadsheetkey)
                        break;
                }
                if (entry != null)
                    InsertRow(service, (WorksheetEntry)entry.Worksheets.Entries[0], parameters);
            }
            catch (Exception e)
            {
                logger.ErrorException("error writing to spreadsheet", e);
            }
        }
Beispiel #2
0
        public GoogleNinjaService(ISpreadsheetConfiguration googleSpreadsheetConfiguration)
        {
            this.googleSpreadsheetConfiguration = googleSpreadsheetConfiguration;

            service = new SpreadsheetsService("tretton37-NinjaBook");
            service.setUserCredentials(googleSpreadsheetConfiguration.Username, googleSpreadsheetConfiguration.Password);
        }
        private SpreadsheetsService AuthenticateGoogleUser(string val)
        {
            SpreadsheetsService service = new SpreadsheetsService("NodeLookupProgram");
            service.setUserCredentials(ConfigurationManager.AppSettings["username"].ToString(), ConfigurationManager.AppSettings["passcode"].ToString());

            return service;
        }
        public SpreadSheet()
        {
            service = new SpreadsheetsService("stock-market");
            service.setUserCredentials("shurai", "$gva99void!");

            SpreadsheetQuery query = new SpreadsheetQuery();
            SpreadsheetFeed feed = service.Query(query);

            SpreadsheetEntry ssentry = (SpreadsheetEntry)feed.Entries[0];

            AtomLink sslink = ssentry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            WorksheetQuery wkquery = new WorksheetQuery(sslink.HRef.ToString());
            WorksheetFeed wkfeed = service.Query(wkquery);
            WorksheetEntry wkentry = (WorksheetEntry)wkfeed.Entries[0];

            listFeedLink = wkentry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
            listQuery = new ListQuery(listFeedLink.HRef.ToString());
            listFeed = service.Query(listQuery);

            Console.WriteLine("Worksheet has {0} rows: ", listFeed.Entries.Count);
            foreach (ListEntry worksheetRow in listFeed.Entries)
            {
                ListEntry.CustomElementCollection elements = worksheetRow.Elements;
                foreach (ListEntry.Custom element in elements)
                {
                    Console.Write(element.Value + "\t");
                }
                Console.WriteLine();
            }
        }
        public ActionResult AllCells()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            SpreadsheetQuery q = new SpreadsheetQuery(App.SheetFeedData);
            var feed = service.Query(q);
            AtomLink l = feed.Entries.First().Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            WorksheetQuery query = new WorksheetQuery(l.HRef.ToString());
            WorksheetFeed f = service.Query(query);

            foreach (var item in f.Entries)
            {
                AtomLink cellFeedLink = item.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
                var cellfeedlink = cellFeedLink.HRef.ToString();

                CellQuery cquery = new CellQuery(cellfeedlink);
                CellFeed cfeed = service.Query(cquery);

                Console.WriteLine("Cells in this worksheet:");
                uint rownum = 2;

                foreach (CellEntry curCell in cfeed.Entries)
                {
                    rownum = curCell.Cell.Row;
                }
            }
            return View(f);
        }
Beispiel #6
0
        public GoogleClient(TrelloStatsConfiguration configuration)
        {
            _configuration = configuration;
            _service = new SpreadsheetsService("trelloStats");
            _service.setUserCredentials(_configuration.GmailEmailAddress, _configuration.GmailPassword);

            _configuration = configuration;
        }
Beispiel #7
0
        public SpreadsheetProxy(Credentials credentials)
        {
            spreadsheetService = new SpreadsheetsService("groundfloor-svc1");
            spreadsheetService.setUserCredentials(credentials.username, credentials.password);

            documentService = new DocumentsService("groundfloor-svc2");
            documentService.setUserCredentials(credentials.username, credentials.password);
        }
		public DatabaseClient(string username, string password) {
			var docService = new DocumentsService("database");
			docService.setUserCredentials(username, password);
			documentService = docService;

			var ssService = new SpreadsheetsService("database");
			ssService.setUserCredentials(username, password);
			spreadsheetService = ssService;
		}
        public IEnumerable<Word> GetWords()
        {
            if (Enabled)
            {
                SpreadsheetsService GoogleService = new SpreadsheetsService("LanguageBooster");

                // FIX ME: Remove credentials from code.
                GoogleService.setUserCredentials("xxx", "xxx");

                SpreadsheetQuery SpreadsheetsQuery = new SpreadsheetQuery();
                SpreadsheetFeed Spreadsheets = GoogleService.Query(SpreadsheetsQuery);

                // Get list of spreadsheets
                foreach (SpreadsheetEntry WordsSheet in Spreadsheets.Entries)
                {
                    System.Diagnostics.Trace.WriteLine(WordsSheet.Title.Text);

                    System.Diagnostics.Trace.WriteLine(WordsSheet.Title.Text);

                    // Get list of worksheets from spreadsgett
                    WorksheetFeed Worksheets = WordsSheet.Worksheets;

                    WorksheetEntry CurrentWorksheet = null;
                    foreach (WorksheetEntry Worksheet in Worksheets.Entries)
                    {
                        CurrentWorksheet = Worksheet;
                        break;
                    }

                    AtomLink CellsLink = CurrentWorksheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
                    CellQuery CellsQuery = new Google.GData.Spreadsheets.CellQuery(CellsLink.HRef.ToString());
                    CellFeed Cells = GoogleService.Query(CellsQuery);

                    Word word = null;
                    // Load actual table data
                    foreach (CellEntry CurrentCell in Cells.Entries)
                    {
                        if (CurrentCell.Column == 1)
                        {
                            word = new Word();
                            word.Question = CurrentCell.Value;
                        }

                        if (CurrentCell.Column == 2)
                        {
                            word.Answer = CurrentCell.Value;
                            System.Diagnostics.Trace.WriteLine(word.Question + " - " + word.Answer);
                            yield return word;
                        }
                    }
                }
            }
        }
Beispiel #10
0
		public SpreadsheetManager( string userName, string password, string applicationName, string clientId, string clientSecret, string redirectUri, string scope )
		{
			oAuthParams = new OAuth2Parameters()
			{
				ClientId = clientId,
				ClientSecret = clientSecret,
				RedirectUri = redirectUri,
				Scope = scope
			};

			_spreadsheetsService = new SpreadsheetsService( applicationName );
			_spreadsheetsService.setUserCredentials( userName, password );
		}
        //
        // GET: /Spreadsheet/
        public ActionResult Index()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("Spreadsheet-GData-Sample-App");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);

            SpreadsheetQuery query = new SpreadsheetQuery();
            var feed = service.Query(query);

            return View(feed);
        }
        public WatchNotify(string googleUserName, string googlePassword, IEmailService mailService)
        {
            if (String.IsNullOrEmpty(googleUserName) || String.IsNullOrEmpty(googlePassword))
                throw new ArgumentException("Please provide google credentials");

            GoogleUserName = googleUserName;
            GooglePassword = googlePassword;

            MySpreadsheetService = new SpreadsheetsService("AuctionWatchNotify");
            MySpreadsheetService.setUserCredentials(GoogleUserName, GooglePassword);

            if (!mailService.CheckConnection())
                throw new ArgumentException("Please pass in a working email service account");

            MyEmailService = mailService;
        }
Beispiel #13
0
        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SpreadsheetsService service = new SpreadsheetsService("dyselon-cardmaker-v1");
                service.setUserCredentials(this.Username.Text, this.Password.Password);
                Service = service;
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Failed to log in with error:\n\n{0}", ex.ToString()));
                return;
            }

            this.DialogResult = true;
            this.Close();
        }
        public ContentResult CSS()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            var cellfeedlink = App.SheetFeedCSS;
            CellQuery cquery = new CellQuery(cellfeedlink);
            CellFeed cfeed = service.Query(cquery);
            string ans = "";

            foreach (CellEntry curCell in cfeed.Entries)
            {
                ans += curCell.Cell.Value;
            }
            return Content(ans, "text/css");
        }
        public void LogIn(string login, string password)
        {
            SpreadsheetsService service = new SpreadsheetsService(applicationName);
            service.setUserCredentials(login, password);

            // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
            SpreadsheetQuery query = new SpreadsheetQuery();
            query.Title = applicationName;
            try
            {

                SpreadsheetFeed feed = service.Query(query);
                internalCredentials.LogIn(login, password);
            }
            catch (Exception e)
            {
                throw new CredentialsException(e.Message);
            }
        }
        public DictionaryTable Download(string sheetName)
        {
            SpreadsheetsService service = new SpreadsheetsService(applicationName);
            service.setUserCredentials(userName, password);
            WorksheetEntry worksheet = this.GetWorksheetEntrees(service).FirstOrDefault(e => e.Title.Text == sheetName);
            if (worksheet == null)
                return null;

            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            cellQuery.MaximumColumn = 2;

            CellFeed cellFeed = service.Query(cellQuery);
            List<DictionaryItem> retval = new List<DictionaryItem>();
            for (int i = 0; i < cellFeed.Entries.Count; i = i + 2)
            {
                retval.Add(
                    new DictionaryItem(new string[] { ((CellEntry)cellFeed.Entries[i]).Value, ((CellEntry)cellFeed.Entries[i + 1]).Value }));
            }
            return new DictionaryTable(sheetName, retval.ToArray());
        }
        //Fetch all Spreadsheets
        public static ArrayList getSpreadsheetList(string userName, string passWord)
        {
            ArrayList spreadsheetList = new ArrayList();

            SpreadsheetsService service = new SpreadsheetsService("GetSpreadsheetsService");

            //You could set it up from DB or config file also. This is not a reccomended way. Just an easy way to show fetching
            service.setUserCredentials(userName, passWord);

            SpreadsheetQuery query = new SpreadsheetQuery();

            SpreadsheetFeed feed = service.Query(query);

            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                spreadsheetList.Add(entry.Title.Text);
            }

            return spreadsheetList;
        }
Beispiel #18
0
        /// <summary>
        /// Creates a new SpreadsheetsService with the user's specified
        /// authentication credentials and runs all of the Spreadsheets
        /// operations above.
        /// </summary>
        private static void RunSample()
        {
            SpreadsheetsService service = new SpreadsheetsService("exampleCo-exampleApp-1");
            service.setUserCredentials(userName, password);

            // Demonstrate printing all spreadsheets and worksheets.
            PrintAllSpreadsheetsAndWorksheets(service);

            // Demonstrate retrieving the list feed for a single worksheet,
            // with the rows (ordered by position) reversed.
            int userChoice = GetUserWorksheetChoice();
            WorksheetEntry entry = allWorksheets[userChoice] as WorksheetEntry;

            RetrieveListFeed(service, entry, true);

            // Demonstrate sending a structured query.
            Console.Write("Enter a structured query to execute: ");
            string queryText = Console.ReadLine();
            StructuredQuery(service, entry, queryText);

            // Demonstrate inserting a new row in the worksheet.
            ListEntry insertedEntry = InsertRow(service, entry);

            // Demonstrate updating the inserted row.
            UpdateRow(service, insertedEntry);

            // Demonstrate deleting the entry.
            insertedEntry.Delete();

            // Demonstrate retrieving a cell feed for a worksheet.
            RetrieveCellFeed(service, entry);

            // Demonstrate a cell range query.
            CellRangeQuery(service, entry);

            // Demonstrate updating a single cell.
            UpdateCell(service, entry);
        }
        public bool Update(Session model)
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            SpreadsheetQuery q = new SpreadsheetQuery(App.SheetFeedData);
            // Make a request to the API and get all spreadsheets.
            SpreadsheetFeed feed = service.Query(q);
            if (feed.Entries.Count == 0)
            {
                return false;
            }

            // TODO: Choose a spreadsheet more intelligently based on your
            // app's needs.
            SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
            Console.WriteLine(spreadsheet.Title.Text);

            // Get the first worksheet of the first spreadsheet.
            // TODO: Choose a worksheet more intelligently based on your
            // app's needs.
            WorksheetFeed wsFeed = spreadsheet.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

            // Fetch the cell feed of the worksheet.
            CellQuery cellQ = new CellQuery(worksheet.CellFeedLink);
            CellFeed cfeed = service.Query(cellQ);

            Console.WriteLine("Cells in this worksheet:");
            uint rownum = 2;
            List<Session> sessions = new List<Session>();
            Session workingSession = new Session();

            uint updaterow = 0;
            foreach (CellEntry curCell in cfeed.Entries)
            {
                if (curCell.Cell.Row > 1)
                {
                    if (curCell.Cell.Row != rownum)
                    {
                        sessions.Add(workingSession);
                        rownum = curCell.Cell.Row;
                        workingSession = new Session();
                    }
                    switch (curCell.Cell.Column)
                    {
                        case 1:
                            workingSession.IID = int.Parse(curCell.Cell.Value);
                            if (workingSession.IID == model.IID)
                            {
                                updaterow = curCell.Cell.Row;
                            }
                            break;
                        case 2:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.Title;
                                curCell.Update();
                            }
                            break;
                        case 3:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.SpeakerDescription;
                                curCell.Update();
                            }
                            break;
                        case 4:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.Description;
                                curCell.Update();
                            }
                            break;
                        case 5:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.Room;
                            curCell.Update();
                            }
                            break;
                        case 6:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.StartHour.ToString();
                            curCell.Update();
                            }
                            break;
                        case 7:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.StartAMPM;
                            curCell.Update();
                            }
                            break;
                        case 8:
                            if (curCell.Cell.Row == updaterow)
                            {
                            curCell.InputValue = model.LengthMin.ToString();
                            curCell.Update();
                            }
                            break;
                        case 9:
                            if (curCell.Cell.Row == updaterow)
                            {
                                curCell.InputValue = model.CSSClass;
                                curCell.Update();
                            }
                            break;
                    }
                }
            }
            return true;
        }
Beispiel #20
0
        public static void GDocSupply(string[] args)
        {
            MUs MUList = new MUs();
            List<string> blackList = new List<string>();

            if (args.Length != 16)
            {
                ConsoleLog.WriteLine("Usage: armysupply eLogin ePassword ePin gLogin gPassword document_name sheet_name do_tanks do_food food_q period max_tanks max_health validation_type(none/MU/citizenship) do_init_block");
                ConsoleLog.WriteLine("Example: armysupply snab_org 123456 1111 [email protected] 54321 \"Army supply\" \"Sheet1\" true true 5 60 8 300 MU false");
                return;
            }

            string eLogin = args[1];
            string ePassword = args[2];
            string ePin = args[3];
            string gLogin = args[4];
            string gPassword = args[5];
            string sDocumentName = args[6];
            string sSheetName = args[7];
            bool bDoTanks = Convert.ToBoolean(args[8]);
            bool bDoFood = Convert.ToBoolean(args[9]);
            int iFoodQ = Convert.ToInt32(args[10]);
            int iPeriod = Convert.ToInt32(args[11]);
            int iMaxTanks = Convert.ToInt32(args[12]);
            int iMaxHP = Convert.ToInt32(args[13]);
            string sValidation = args[14];
            bool bDoInitBlock = Convert.ToBoolean(args[15]);

            string token = "";

            ConsoleLog.WriteLine("Loading document...");
            #region Open sheet
            SpreadsheetsService sheetService = new SpreadsheetsService("EArmy supply");
            sheetService.setUserCredentials(gLogin, gPassword);
            SpreadsheetQuery sheetQuery = new SpreadsheetQuery();
            SpreadsheetFeed sheetFeed = sheetService.Query(sheetQuery);

            SpreadsheetEntry sheetSnab = null;
            foreach (SpreadsheetEntry entry in sheetFeed.Entries)
            {
                if (entry.Title.Text == sDocumentName)
                {
                    sheetSnab = entry;
                    break;
                }
            }
            if (sheetSnab == null)
            {
                ConsoleLog.WriteLine("Document '" + sDocumentName + "' not found");
                return;
            }

            AtomLink sheetLink = sheetSnab.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

            WorksheetQuery wsQuery = new WorksheetQuery(sheetLink.HRef.ToString());
            WorksheetFeed wsFeed = sheetService.Query(wsQuery);

            WorksheetEntry wsSnab = null;
            WorksheetEntry wsSettings = null;
            foreach (WorksheetEntry ws in wsFeed.Entries)
            {
                if (ws.Title.Text == sSheetName)
                {
                    wsSnab = ws;
                }
                if (ws.Title.Text == "Settings")
                {
                    wsSettings = ws;
                }
            }
            if (wsSnab == null)
            {
                ConsoleLog.WriteLine("Page '" + sSheetName + "' not found");
                return;
            }
            if (wsSettings != null)
            {
                LoadSettings(sheetService, wsSettings, MUList, blackList);
            }
            #endregion

            #region Login to supplier
            DonaterBot bt = new DonaterBot(
                eLogin,
                eLogin,
                ePassword,
                ePin,
                "Mozilla//4.0 (compatible; MSIE 7.0; Windows NT 6.0)",
                Globals.BotConfig.AntiGateKey,
                Globals.BotConfig.precaptchaBufferSize);
            bt.HttpClient.SetProxy(null, null);
            bool loggedIn = false;
            int iTryToConnect = 0;
            System.Random rnd = new System.Random();
            #endregion

            while (true)
            {
                try
                {
                    ConsoleLog.WriteLine("Loading cells...");
                    #region Query cells
                    AtomLink cellLink = wsSnab.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);

                    CellQuery query = new CellQuery(cellLink.HRef.ToString());
                    query.ReturnEmpty = ReturnEmptyCells.yes;
                    query.MaximumColumn = 13;
                    CellFeed feed = sheetService.Query(query);

                    List<ItemStorage> lines = new List<ItemStorage>();
                    ItemStorage item = null;
                    #endregion

                    #region Load cells
                    lines.Clear();
                    foreach (CellEntry curCell in feed.Entries)
                    {
                        if (curCell.Cell.Row < 2) continue;

                        item = lines.Find(l => l.row == curCell.Cell.Row);
                        if (item == null)
                        {
                            item = new ItemStorage();
                            lines.Add(item);
                            item.row = curCell.Cell.Row;
                        }

                        if (curCell.Cell.Column == 1)       // time
                        {
                            item.time = curCell.Cell.Value;
                        }
                        if (curCell.Cell.Column == 2)       // login
                        {
                            item.login = curCell.Cell.Value;
                        }
                        if (curCell.Cell.Column == 3)       // link to profile
                        {
                            item.personID = curCell.Cell.Value;
                            try
                            {
                                item.personID = item.personID.Substring(item.personID.LastIndexOf('/') + 1);
                                Convert.ToInt64(item.personID);
                            }
                            catch
                            {
                                item.personID = "";
                            }
                            // Cut ID from link
                        }
                        if (curCell.Cell.Column == 4)       // wellness
                        {
                            try
                            {
                                item.wellness = Convert.ToInt32(curCell.Cell.Value);
                            }
                            catch
                            {
                                item.wellness = 0;
                            }
                        }
                        if (curCell.Cell.Column == 5)       // needed tanks
                        {
                            try
                            {
                                item.tanks = Convert.ToInt32(curCell.Cell.Value);
                            }
                            catch
                            {
                                item.tanks = 0;
                            }
                        }
                        if (curCell.Cell.Column == 6)       // military unit
                        {
                            item.militaryUnit = curCell.Cell.Value;
                        }
                        if (curCell.Cell.Column == 8)       // done tanks
                        {
                            item.doneTanksCell = curCell;
                            try
                            {
                                item.doneTanks = Convert.ToInt32(curCell.Cell.Value);
                            }
                            catch
                            {
                                item.wellness = 0;
                            }
                        }
                        if (curCell.Cell.Column == 9)       // done food q
                        {
                            try
                            {
                                item.doneFoodQ = Convert.ToInt32(curCell.Cell.Value);
                            }
                            catch
                            {
                                item.doneFoodQ = 0;
                            }
                            item.doneFoodQCell = curCell;
                        }
                        if (curCell.Cell.Column == 10)      // done food
                        {
                            item.doneFoodCell = curCell;
                            try
                            {
                                item.doneFood = Convert.ToInt32(curCell.Cell.Value);
                            }
                            catch
                            {
                                item.doneFood = 0;
                            }
                        }
                        if (curCell.Cell.Column == 11)       // autocomment cell
                        {
                            item.comment = curCell.Cell.Value;
                            item.commentCell = curCell;
                        }
                        if (curCell.Cell.Column == 12)       // tanks limit cell
                        {
                            try
                            {
                                if (!String.IsNullOrEmpty(curCell.Cell.Value))
                                    item.tanksLimit = Convert.ToInt32(curCell.Cell.Value);
                                else
                                    item.tanksLimit = -1;
                            }
                            catch
                            {
                                item.tanksLimit = -1;
                            }

                            item.tanksLimitCell = curCell;
                        }
                        if (curCell.Cell.Column == 13)       // HP limit cell
                        {
                            try
                            {
                                if (!String.IsNullOrEmpty(curCell.Cell.Value))
                                    item.foodLimit = Convert.ToInt32(curCell.Cell.Value);
                                else
                                    item.foodLimit = -1;
                            }
                            catch
                            {
                                item.foodLimit = -1;
                            }

                            item.foodLimitCell = curCell;
                        }
                    }
                    ConsoleLog.WriteLine("Items loaded: " + lines.Count);
                    #endregion

                    #region Parce cells
                    int row = 0;
                    List<ItemStorage> tmpList = new List<ItemStorage>(lines);
                    foreach (ItemStorage testItem in tmpList)
                    {
                        row++;

                        if (string.IsNullOrEmpty(testItem.time))
                        {
                            lines.Remove(testItem);
                            continue;
                        }

                        if (!string.IsNullOrEmpty(testItem.comment))
                        {
                            lines.Remove(testItem);
                            continue;
                        }

                        if (string.IsNullOrEmpty(testItem.personID))
                        {
                            lines.Remove(testItem);
                            testItem.commentCell.Cell.InputValue = "Bad profile";
                            testItem.commentCell.Update();
                            continue;
                        }

                        if (blackList.Contains(testItem.login))
                        {
                            lines.Remove(testItem);
                            testItem.commentCell.Cell.InputValue = "Blacklist";
                            testItem.commentCell.Update();
                            continue;
                        }

                        if ((sValidation.ToLower() == "mu") &&
                            (String.IsNullOrEmpty(MUList[testItem.militaryUnit])))
                        {
                            lines.Remove(testItem);
                            testItem.commentCell.Cell.InputValue = "MU not in list";
                            testItem.commentCell.Update();
                            continue;
                        }

                        if ((testItem.wellness == 0) && (testItem.tanks == 0))
                        {
                            lines.Remove(testItem);
                            testItem.commentCell.Cell.InputValue = "Bad wellness/tanks";
                            testItem.commentCell.Update();
                            continue;
                        }

                        //if (testItem.tanks > 30)
                        //{
                        //    lines.Remove(testItem);
                        //    testItem.commentCell.Cell.InputValue = "Bad tanks";
                        //    testItem.commentCell.Update();
                        //    continue;
                        //}

                        if (tmpList.Find(o => (o.personID == testItem.personID && o.viewedForDuplicate)) != null)
                        {
                            lines.Remove(testItem);
                            testItem.commentCell.Cell.InputValue = "Duplicate record";
                            testItem.commentCell.Update();
                            continue;
                        }

                        if (testItem.tanksLimit == -1)
                        {
                            if (bDoInitBlock)
                            {
                                testItem.tanksLimit = 0;
                            }
                            else
                            {
                                testItem.tanksLimit = iMaxTanks;
                            }
                            testItem.tanksLimitCell.Cell.InputValue = testItem.tanksLimit.ToString();
                            testItem.tanksLimitCell.Update();
                        }

                        if (testItem.foodLimit == -1)
                        {
                            if (bDoInitBlock)
                            {
                                testItem.foodLimit = 0;
                            }
                            else
                            {
                                testItem.foodLimit = iMaxHP;
                            }
                            testItem.foodLimitCell.Cell.InputValue = testItem.foodLimit.ToString();
                            testItem.foodLimitCell.Update();
                        }

                        testItem.viewedForDuplicate = true;

                        ConsoleLog.WriteLine(
                            row + ": " +
                            testItem.time + ";" +
                            testItem.login + ";" +
                            testItem.personID + ";" +
                            testItem.wellness + ";" +
                            testItem.tanks + ";" +
                            testItem.doneTanks + ";" +
                            testItem.doneFoodQ + ";" +
                            testItem.doneFood
                            );
                    }
                    #endregion

                    #region Log in
                    if (!loggedIn)
                    {
                        iTryToConnect++;
                        if (iTryToConnect > 10)
                            break;

                        ConsoleLog.WriteLine("Trying to login (" + (iTryToConnect).ToString() + ")...");
                        if (bt.Login())
                        {
                            ConsoleLog.WriteLine("Logged in!");
                            iTryToConnect = 0;
                            loggedIn = true;
                        }
                        else
                        {
                            ConsoleLog.WriteLine("Login failed!");
                            System.Threading.Thread.Sleep(1000);
                            continue;
                        }
                    }
                    #endregion

                    //Process donations
                    foreach (ItemStorage donateItem in lines)
                    {
                        ConsoleLog.WriteLine("Donating to: login="******", id=" + donateItem.personID);

                        #region Calculate quantities
                        int foodQty;
                        if ((bDoFood) && (donateItem.wellness > 0) && (donateItem.doneFoodQ == 0))
                        {
                            foodQty = Convert.ToInt32(Math.Round((double)((double)Math.Min(donateItem.wellness, donateItem.foodLimit) / (iFoodQ * 2))));
                            foodQty = foodQty - donateItem.doneFood;
                        }
                        else
                        {
                            foodQty = 0;
                        }

                        int tankQty;

                        if (bDoTanks)
                        {
                            tankQty = Math.Min(donateItem.tanks, donateItem.tanksLimit);
                            tankQty = tankQty - donateItem.doneTanks;
                        }
                        else
                        {
                            tankQty = 0;
                        }

                        if ((foodQty <= 0) && (tankQty <= 0))
                        {
                            ConsoleLog.WriteLine("Nothing to donate");
                            continue;
                        }
                        #endregion

                        #region Open pages and validate
                        string srcPage = "http://www.erepublik.com/en/citizen/profile/" + donateItem.personID;

                        bt.CustomRequest(srcPage);

                        if (!bt.GetLastResponse().Contains("career_tab_content"))
                        {
                            ConsoleLog.WriteLine("Profile page loading failed. Try to relogin...");
                            loggedIn = false;
                            break;
                        }

                        if (bt.GetLastResponse().IndexOf("alt=\"" + donateItem.login.Trim() + "\"", StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            ConsoleLog.WriteLine("Donating login validation failed");
                            donateItem.commentCell.Cell.InputValue = "Profile != Login";
                            donateItem.commentCell.Update();
                            continue;
                        }
                        else
                        {
                            ConsoleLog.WriteLine("Login validated");
                        }

                        if ((sValidation.ToLower() == "mu") &&
                            (bt.GetLastResponse().IndexOf("alt=\"" + MUList[donateItem.militaryUnit.Trim()] + "\"", StringComparison.OrdinalIgnoreCase) == -1))
                        {
                            ConsoleLog.WriteLine("Donating MU validation failed (" + MUList[donateItem.militaryUnit.Trim()] + ")");
                            ConsoleLog.WriteLine(bt.GetLastResponse(), "Storage page");
                            donateItem.commentCell.Cell.InputValue = "Profile != MU";
                            donateItem.commentCell.Update();
                            continue;
                        }
                        else
                        {
                            ConsoleLog.WriteLine("MU validated");
                        }

                        srcPage = "http://economy.erepublik.com/en/citizen/donate/" + donateItem.personID;

                        bt.CustomRequest(srcPage);

                        if (bt.CheckPin(true))
                        {
                            bt.SubmitPin();
                        }

                        if (bt.CheckPin(true))
                        {
                            ConsoleLog.WriteLine("Pin validation failed");
                            break;
                        }

                        if (!bt.GetLastResponse().Contains("<th colspan=\"4\" valign=\"middle\">Your storage</th>"))
                        {
                            ConsoleLog.WriteLine("Donate page loading failed. Try to relogin...");
                            loggedIn = false;
                            break;
                        }

                        token = CommonUtils.GetStringBetween(
                            bt.GetLastResponse(),
                            "donate_form[_csrf_token]\" value=\"",
                            "\"");
                        #endregion

                        #region Donate food
                        if (foodQty > 0)
                        {
                            ConsoleLog.WriteLine("Donating food: " + foodQty + " (q" + iFoodQ + ")");

                            if (bt.DonateItem(foodQty.ToString(), Goods.Food.ToString(), iFoodQ.ToString(), token, srcPage))
                            //if (true)
                            {
                                ConsoleLog.WriteLine("Donating food success");
                                donateItem.doneFoodQCell.Cell.InputValue = iFoodQ.ToString();
                                donateItem.doneFoodQCell.Update();
                                donateItem.doneFoodCell.Cell.InputValue = (donateItem.doneFood + foodQty).ToString();
                                donateItem.doneFoodCell.Update();
                            }
                            else
                            {
                                ConsoleLog.WriteLine("Donating food failed");
                                //ConsoleLog.WriteLine(bt.GetLastResponse(), "DonateLog.txt");
                            }

                            ConsoleLog.WriteLine("Wait 5 sec...");
                            System.Threading.Thread.Sleep(5 * 1000);
                        }
                        else
                        {
                            ConsoleLog.WriteLine("No food needed");
                        }
                        #endregion

                        #region Donate tanks
                        if (tankQty > 0)
                        {
                            ConsoleLog.WriteLine("Donating tanks: " + tankQty);

                            if (bt.DonateItem(tankQty.ToString(), Goods.Weapon.ToString(), 5.ToString(), token, srcPage))
                            //if (true)
                            {
                                ConsoleLog.WriteLine("Donating tanks success");
                                donateItem.doneTanksCell.Cell.InputValue = (donateItem.doneTanks + tankQty).ToString();
                                donateItem.doneTanksCell.Update();
                            }
                            else
                            {
                                ConsoleLog.WriteLine("Donating tanks failed");
                                ConsoleLog.WriteLine(bt.GetLastResponse(), "DonateLog.txt");
                            }

                            ConsoleLog.WriteLine("Wait 5 sec...");
                            System.Threading.Thread.Sleep(5 * 1000);
                        }
                        else
                        {
                            ConsoleLog.WriteLine("No tanks needed");
                        }
                        #endregion
                    }
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Donater error: " + e.Message);
                    ConsoleLog.WriteLine(bt.GetLastResponse(), "Responses.txt");
                }

                ConsoleLog.WriteLine("Waiting for next check");
                //break;
                System.Threading.Thread.Sleep(iPeriod * 1000);
            }

            ConsoleLog.WriteLine("It's OK :)");
        }
        public ActionResult Schedule()
        {
            SpreadsheetsService service;

            service = new SpreadsheetsService("DevFestEvent");
            service.setUserCredentials(
                ConfigurationManager.AppSettings["GoogleUser"],
                 ConfigurationManager.AppSettings["GoogleUserPassword"]);
            var cellfeedlink = App.SheetFeedData;

            CellQuery cquery = new CellQuery(cellfeedlink);
            CellFeed cfeed = service.Query(cquery);

            Console.WriteLine("Cells in this worksheet:");
            uint rownum = 2;
            List<Session> sessions = new List<Session>();
            Session workingSession = new Session();

            foreach (CellEntry curCell in cfeed.Entries)
            {
                if (curCell.Cell.Row > 1)
                {
                    if (curCell.Cell.Row != rownum)
                    {
                        sessions.Add(workingSession);
                        rownum = curCell.Cell.Row;
                        workingSession = new Session();
                    }
                    switch (curCell.Cell.Column)
                    {
                        case 1:
                            workingSession.IID = int.Parse(curCell.Cell.Value);
                            break;
                        case 2:
                            workingSession.Title = curCell.Cell.Value;
                            break;
                        case 3:
                            workingSession.SpeakerDescription = curCell.Cell.Value;
                            break;
                        case 4:
                            workingSession.Description = curCell.Cell.Value;
                            break;
                        case 5:
                            workingSession.Room = curCell.Cell.Value;
                            break;
                        case 6:
                            workingSession.StartHour = int.Parse(curCell.Cell.Value);
                            break;
                        case 7:
                            workingSession.StartAMPM = curCell.Cell.Value;
                            break;
                        case 8:
                            workingSession.LengthMin = int.Parse(curCell.Cell.Value);
                            break;
                        case 9:
                            workingSession.CSSClass = curCell.Cell.Value;
                            break;
                    }
                }
            }
            sessions.Add(workingSession);
            return View(sessions);
        }
        public static IEnumerable<InitCategory> AllCategories()
        {
            try
            {
                if (_allCategories == null)
                {
                    // These are all of the steps used in the spreadsheet sample app, just condensed.
                    var ssService = new SpreadsheetsService("MueVue Category Management App");
                    ssService.setUserCredentials(LoginCredentials[0], LoginCredentials[1]);

                    // Find the right worksheet...
                    var entries = ssService.Query(new SpreadsheetQuery()).Entries;
                    if (entries == null)
                    {
                        throw new InvalidOperationException("Query(new SpreadsheetQuery()) failed.");
                    }
                    var ssAtomEntry =
                        entries.FirstOrDefault(
                            e =>
                            e.Title.Text.Equals("CategoriesTagsMaterials", StringComparison.InvariantCultureIgnoreCase));
                    if (ssAtomEntry == null)
                    {
                        throw new InvalidOperationException("Failed to retrieve spreadsheet CategoriesTagsMaterials.");
                    }
                    string categoriesWorksheetUrl =
                        ssAtomEntry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel,
                                                      AtomLink.ATOM_TYPE).HRef.Content;
                    var workSheetFeed = ssService.Query(new WorksheetQuery(categoriesWorksheetUrl));
                    var categoriesWorksheet =
                        workSheetFeed.Entries.FirstOrDefault(
                            ae => ae.Title.Text.Equals("Categories", StringComparison.InvariantCultureIgnoreCase));
                    if (categoriesWorksheet == null)
                    {
                        throw new InvalidOperationException("Failed to retrieve worksheet Categories.");
                    }
                    // Then get the cells.
                    string categoriesCellFeedUrl =
                        categoriesWorksheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel,
                                                              AtomLink.ATOM_TYPE).HRef.Content;

                    var catFeed = ssService.Query(new CellQuery(categoriesCellFeedUrl));
                    if (catFeed == null)
                    {
                        throw new InvalidOperationException("Failed to retrieve cells.");
                    }

                    var catsAndGuids = new List<string[]>();

                    // TODO: make the indices flexible
                    for (uint i = 2; i <= 24; i++)
                    {
                        CellEntry cat = catFeed[i, 1];
                        CellEntry guid = catFeed[i, 2];
                        catsAndGuids.Add(new[] { cat.Value, guid.Value });
                    }

                    Console.WriteLine(catsAndGuids.Count);

                    _allCategories = catsAndGuids.Select(
                            cat =>
                            new InitCategory { Id = Guid.Parse(cat[1]), Name = cat[0], Tags = null, Resources = null }).ToArray();
                }
                return _allCategories;
            }
            catch (Exception e)
            {
                Console.WriteLine("Worksheet query failed. \n" + e.Message);
                return null;
            }
        }
        public string isCanLoginIn()
        {
            try
            {
                SpreadsheetsService service = new SpreadsheetsService("whatsappshower");
                service.setUserCredentials("*****@*****.**", "e4rst6rh");

                SpreadsheetQuery query = new SpreadsheetQuery();
                SpreadsheetFeed feed = service.Query(query);

                

                SpreadsheetEntry whatsAppShowerCerEntry = null;
                foreach (SpreadsheetEntry entry in feed.Entries)
                {
                    //Console.WriteLine(entry.Title.Text);
                    if ("whatsAppShowerCer".Equals(entry.Title.Text))
                    {
                        whatsAppShowerCerEntry = entry;
                    }

                }
                if (whatsAppShowerCerEntry == null)
                {
                    return null;
                }



                AtomLink link = whatsAppShowerCerEntry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                WorksheetQuery worksheetQueryQuery = new WorksheetQuery(link.HRef.ToString());
                WorksheetFeed worksheetQueryFeed = service.Query(worksheetQueryQuery);
                WorksheetEntry whatsAppShowerCerWorksheet = null;
                foreach (WorksheetEntry worksheet in worksheetQueryFeed.Entries)
                {
                    if ("1".Equals(worksheet.Title.Text))
                    {
                        whatsAppShowerCerWorksheet = worksheet;
                    }
                }
                if (whatsAppShowerCerWorksheet == null)
                {
                    return null;
                }

                AtomLink cellFeedLink = whatsAppShowerCerWorksheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);

                CellQuery cellQueryQuery = new CellQuery(cellFeedLink.HRef.ToString());
                CellFeed cellQueryFeed = service.Query(cellQueryQuery);

                bool foundToken = false;
                foreach (CellEntry curCell in cellQueryFeed.Entries)
                {
                    if (foundToken)
                    {
                        return curCell.Cell.Value;
                    }
                    if (curCell.Cell.Column == 1)
                    {
                        if (curCell.Cell.Value.Equals(WhatsappProperties.Instance.AppToken))
                        {
                            foundToken = true;
                        }
                    }

                }
            }
            catch (Exception e)
            {
                systemLog.Error(e);
            }

            return null;
        }
Beispiel #24
0
        private void ExportInformation()
        {
            SpreadsheetsService service = new SpreadsheetsService("EVEBendSpreadsheetV1");
            service.setUserCredentials("GOOGLE DOCS USERNAME", "GOOGLE PASSWORD");
            SpreadsheetQuery query = new SpreadsheetQuery();
            SpreadsheetFeed feed = service.Query(query);

            if (feed.Entries.Count == 0)
            {
                EnableButtons();
                lblNews.Visible = false;
                lblEditSuccessful.Text = "Export Failed";
                lblEditSuccessful.Visible = true;
            }
            else
            {
                SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
                if (spreadsheet.Title.Text.ToString() == "Ore Values")
                {
                    rtbPrices.Text += "\nSearching spreadsheet: " + spreadsheet.Title.Text;

                    WorksheetFeed wsFeed = spreadsheet.Worksheets;
                    WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[1];
                    rtbPrices.Text += "\nEditing worksheet: " + worksheet.Title.Text;

                    CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
                    CellFeed cellFeed = service.Query(cellQuery);

                    foreach (CellEntry cell in cellFeed.Entries)
                    {
                        if (cell.Title.Text == "C1")
                        {
                            cell.InputValue = DateTime.Now.ToShortDateString().ToString() + " Avg Prices";
                            cell.Update();
                        }

                        #region Cells G2 to N2

                        //Tritanium
                        if (cell.Title.Text == "G2")
                        {
                            cell.InputValue = EVE.Tritanium.ToString();
                            cell.Update();
                        }
                        //Pyerite
                        if (cell.Title.Text == "H2")
                        {
                            cell.InputValue = EVE.Pyerite.ToString();
                            cell.Update();
                        }
                        //Mexallon
                        if (cell.Title.Text == "I2")
                        {
                            cell.InputValue = EVE.Mexallon.ToString();
                            cell.Update();
                        }
                        //Isogen
                        if (cell.Title.Text == "J2")
                        {
                            cell.InputValue = EVE.Isogen.ToString();
                            cell.Update();
                        }
                        //Nocxium
                        if (cell.Title.Text == "K2")
                        {
                            cell.InputValue = EVE.Nocxium.ToString();
                            cell.Update();
                        }
                        //Zydrine
                        if (cell.Title.Text == "L2")
                        {
                            cell.InputValue = EVE.Zydrine.ToString();
                            cell.Update();
                        }
                        //Megacyte
                        if (cell.Title.Text == "M2")
                        {
                            cell.InputValue = EVE.Megacyte.ToString();
                            cell.Update();
                        }
                        //Morphite
                        if (cell.Title.Text == "N2")
                        {
                            cell.InputValue = EVE.Morphite.ToString();
                            cell.Update();
                        }

                        #endregion

                        #region Cells C3 to C23

                        //Veldspar
                        if (cell.Title.Text == "C3")
                        {
                            cell.InputValue = EVE.Veldspar.ToString();
                            cell.Update();
                        }
                        //Concentrated Veldspar
                        if (cell.Title.Text == "C4")
                        {
                            cell.InputValue = EVE.ConcVeldspar.ToString();
                            cell.Update();
                        }
                        //Dense Veldspar
                        if (cell.Title.Text == "C5")
                        {
                            cell.InputValue = EVE.DenseVeldspar.ToString();
                            cell.Update();
                        }
                        //Scordite
                        if (cell.Title.Text == "C6")
                        {
                            cell.InputValue = EVE.Scordite.ToString();
                            cell.Update();
                        }
                        //Condensed Scordite
                        if (cell.Title.Text == "C7")
                        {
                            cell.InputValue = EVE.CondScordite.ToString();
                            cell.Update();
                        }
                        //Massive Scordite
                        if (cell.Title.Text == "C8")
                        {
                            cell.InputValue = EVE.MassScordite.ToString();
                            cell.Update();
                        }
                        //Pyroxeres
                        if (cell.Title.Text == "C9")
                        {
                            cell.InputValue = EVE.Pyroxeres.ToString();
                            cell.Update();
                        }
                        //Solid Pyroxeres
                        if (cell.Title.Text == "C10")
                        {
                            cell.InputValue = EVE.SolidPyroxeres.ToString();
                            cell.Update();
                        }
                        //Viscous Pyroxeres
                        if (cell.Title.Text == "C11")
                        {
                            cell.InputValue = EVE.ViscousPyroxeres.ToString();
                            cell.Update();
                        }
                        //Plagioclase
                        if (cell.Title.Text == "C12")
                        {
                            cell.InputValue = EVE.Plagioclase.ToString();
                            cell.Update();
                        }
                        //Azure Plagioclase
                        if (cell.Title.Text == "C13")
                        {
                            cell.InputValue = EVE.AzurePlagio.ToString();
                            cell.Update();
                        }
                        //Rich Plagioclase
                        if (cell.Title.Text == "C14")
                        {
                            cell.InputValue = EVE.RichPlagio.ToString();
                            cell.Update();
                        }
                        //Omber
                        if (cell.Title.Text == "C15")
                        {
                            cell.InputValue = EVE.Omber.ToString();
                            cell.Update();
                        }
                        //Silvery Omber
                        if (cell.Title.Text == "C16")
                        {
                            cell.InputValue = EVE.SilveryOmber.ToString();
                            cell.Update();
                        }
                        //Golden Omber
                        if (cell.Title.Text == "C17")
                        {
                            cell.InputValue = EVE.GoldenOmber.ToString();
                            cell.Update();
                        }
                        //Kernite
                        if (cell.Title.Text == "C18")
                        {
                            cell.InputValue = EVE.Kernite.ToString();
                            cell.Update();
                        }
                        //Luminous Kernite
                        if (cell.Title.Text == "C19")
                        {
                            cell.InputValue = EVE.LuminKernite.ToString();
                            cell.Update();
                        }
                        //Fiery Kernite
                        if (cell.Title.Text == "C20")
                        {
                            cell.InputValue = EVE.FieryKernite.ToString();
                            cell.Update();
                        }
                        //Jaspet
                        if (cell.Title.Text == "C21")
                        {
                            cell.InputValue = EVE.Jaspet.ToString();
                            cell.Update();
                        }
                        //Pure Jaspet
                        if (cell.Title.Text == "C22")
                        {
                            cell.InputValue = EVE.PureJaspet.ToString();
                            cell.Update();
                        }
                        //Pristine Jaspet
                        if (cell.Title.Text == "C23")
                        {
                            cell.InputValue = EVE.PrisJaspet.ToString();
                            cell.Update();
                        }

                        #endregion

                        #region Cells C24 to C50

                        //Hemorphite
                        if (cell.Title.Text == "C24")
                        {
                            cell.InputValue = EVE.Hemorphite.ToString();
                            cell.Update();
                        }
                        //Vivid Hemorphite
                        if (cell.Title.Text == "C25")
                        {
                            cell.InputValue = EVE.VividHemorphite.ToString();
                            cell.Update();
                        }
                        //Radiant Hemorphite
                        if (cell.Title.Text == "C26")
                        {
                            cell.InputValue = EVE.RadiantHemorphite.ToString();
                            cell.Update();
                        }
                        //Hedbergite
                        if (cell.Title.Text == "C27")
                        {
                            cell.InputValue = EVE.Hedbergite.ToString();
                            cell.Update();
                        }
                        //Vitric Hedbergite
                        if (cell.Title.Text == "C28")
                        {
                            cell.InputValue = EVE.VitricHedbergite.ToString();
                            cell.Update();
                        }
                        //Glazed Hedbergite
                        if (cell.Title.Text == "C29")
                        {
                            cell.InputValue = EVE.GlazedHedbergite.ToString();
                            cell.Update();
                        }
                        //Gneiss
                        if (cell.Title.Text == "C30")
                        {
                            cell.InputValue = EVE.Gneiss.ToString();
                            cell.Update();
                        }
                        //Iridescent Gneiss
                        if (cell.Title.Text == "C31")
                        {
                            cell.InputValue = EVE.IridescentGneiss.ToString();
                            cell.Update();
                        }
                        //Prismatic Gneiss
                        if (cell.Title.Text == "C32")
                        {
                            cell.InputValue = EVE.PrismaticGneiss.ToString();
                            cell.Update();
                        }
                        //Dark Ochre
                        if (cell.Title.Text == "C33")
                        {
                            cell.InputValue = EVE.DarkOchre.ToString();
                            cell.Update();
                        }
                        //Onyx Ochre
                        if (cell.Title.Text == "C34")
                        {
                            cell.InputValue = EVE.OnyxOchre.ToString();
                            cell.Update();
                        }
                        //Obsidian Ochre
                        if (cell.Title.Text == "C35")
                        {
                            cell.InputValue = EVE.ObsidianOchre.ToString();
                            cell.Update();
                        }
                        //Spodumain
                        if (cell.Title.Text == "C36")
                        {
                            cell.InputValue = EVE.Spodumain.ToString();
                            cell.Update();
                        }
                        //Bright Spodumain
                        if (cell.Title.Text == "C37")
                        {
                            cell.InputValue = EVE.BrightSpodumain.ToString();
                            cell.Update();
                        }
                        //Gleaming Spodumain
                        if (cell.Title.Text == "C38")
                        {
                            cell.InputValue = EVE.GleamingSpodumain.ToString();
                            cell.Update();
                        }
                        //Crokite
                        if (cell.Title.Text == "C39")
                        {
                            cell.InputValue = EVE.Crokite.ToString();
                            cell.Update();
                        }
                        //Sharp Crokite
                        if (cell.Title.Text == "C40")
                        {
                            cell.InputValue = EVE.SharpCrokite.ToString();
                            cell.Update();
                        }
                        //Crystalline Crokite
                        if (cell.Title.Text == "C41")
                        {
                            cell.InputValue = EVE.CrystallineCrokite.ToString();
                            cell.Update();
                        }
                        //Bistot
                        if (cell.Title.Text == "C42")
                        {
                            cell.InputValue = EVE.Bistot.ToString();
                            cell.Update();
                        }
                        //Triclinic Bistot
                        if (cell.Title.Text == "C43")
                        {
                            cell.InputValue = EVE.TriclinicBistot.ToString();
                            cell.Update();
                        }
                        //Monoclinic Bistot
                        if (cell.Title.Text == "C44")
                        {
                            cell.InputValue = EVE.MonoclinicBistot.ToString();
                            cell.Update();
                        }
                        //Arkonor
                        if (cell.Title.Text == "C45")
                        {
                            cell.InputValue = EVE.Arkonor.ToString();
                            cell.Update();
                        }
                        //Crimson Arkonor
                        if (cell.Title.Text == "C46")
                        {
                            cell.InputValue = EVE.CrimsonArkonor.ToString();
                            cell.Update();
                        }
                        //Prime Arkonor
                        if (cell.Title.Text == "C47")
                        {
                            cell.InputValue = EVE.PrimeArkonor.ToString();
                            cell.Update();
                        }
                        //Mercoxit
                        if (cell.Title.Text == "C48")
                        {
                            cell.InputValue = EVE.Mercoxit.ToString();
                            cell.Update();
                        }
                        //Magma Mercoxit
                        if (cell.Title.Text == "C49")
                        {
                            cell.InputValue = EVE.MagmaMercoxit.ToString();
                            cell.Update();
                        }
                        //Vitreous Mercoxit
                        if (cell.Title.Text == "C50")
                        {
                            cell.InputValue = EVE.VitreousMercoxit.ToString();
                            cell.Update();
                        }

                        #endregion
                    }

                    lblNews.Visible = false;
                    lblEditSuccessful.Text = "Export Successful";
                    lblEditSuccessful.Visible = true;
                }
                else
                {
                    lblNews.Visible = false;
                    lblEditSuccessful.Text = "Spreadsheet not found";
                    lblEditSuccessful.Visible = true;
                }
            }
        }
        public formatSheet(string Username, string Password, string Sheet, string Worksheet)
        {
            dt = new DataTable();
            try
            {
                SpreadsheetsService service = new
                SpreadsheetsService("Anachrophobe");
                service.setUserCredentials(Username, Password);
                SpreadsheetQuery query = new SpreadsheetQuery();
                query.Title = Sheet;
                SpreadsheetFeed feed = service.Query(query);
                if (feed.Entries.Count != 1) return;

                AtomLink link =
                    feed.Entries[0].Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel,
                    null);
                WorksheetQuery worksheetQuery = new
                WorksheetQuery(link.HRef.ToString());
                worksheetQuery.Title = Worksheet;
                WorksheetFeed worksheetFeed =
                    service.Query(worksheetQuery);
                if (worksheetFeed.Entries.Count != 1) return;

                WorksheetEntry worksheet =
                    (WorksheetEntry)worksheetFeed.Entries[0];

                AtomLink listFeedLink =
                    worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                ListQuery listQuery = new
                    ListQuery(listFeedLink.HRef.ToString());
                ListFeed listFeed = service.Query(listQuery);
                // define the table's schema
                dt.Columns.Add(new DataColumn("A", typeof(string)));
                dt.Columns.Add(new DataColumn("B", typeof(string)));
                dt.Columns.Add(new DataColumn("C", typeof(string)));
                dt.Columns.Add(new DataColumn("D", typeof(string)));
                foreach (ListEntry worksheetRow in listFeed.Entries)
                {
                    string station = string.Empty;
                    string scanData =
                        worksheetRow.Elements[0].Value.ToString();
                    string scanData1 =
                        worksheetRow.Elements[1].Value.ToString();
                    string[] arSD = new string[100];

                    DataRow dr = dt.NewRow();
                    dr["A"] = scanData;
                    dr["B"] = scanData1;
                    dt.Rows.Add(dr);

                }

                //dgwTabla.DataSource = dt;

            }

            catch (Exception ex)
            {
            }
        }
Beispiel #26
0
        private void Login_UsrPwd()
        {
            string USERNAME = "******";
            string PASSWORD = "******";

            service = new SpreadsheetsService("MySpreadsheetIntegration-v1");
            service.setUserCredentials(USERNAME, PASSWORD);
        }
Beispiel #27
0
    public string GetSpreadsheets(Hashtable State, RadComboBox Spreadsheets, string username, string password)
    {
        try
        {
            SpreadsheetsService service = new SpreadsheetsService(State["SelectedApp"].ToString());

            service.setUserCredentials(username, password);

            //get all spreadsheets
            Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();
            SpreadsheetFeed feed = service.Query(query);

            Spreadsheets.Items.Clear();
            Spreadsheets.Items.Add(new RadComboBoxItem("Select Spreadsheet ->", "->"));
            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                string spreadsheet_name = entry.Title.Text;
                Spreadsheets.Items.Add(new RadComboBoxItem(spreadsheet_name, spreadsheet_name));
            }
            return "OK";
        }
        catch (Exception ex)
        {
            Util util = new Util();
            util.LogError(State, ex);
            return ex.Message;
        }
    }
Beispiel #28
0
    public string ParseGoogleDocsSpreadsheet(Hashtable State,string use_spreadsheet_name, string username, string password)
    {
        try
        {
            SpreadsheetsService service = new SpreadsheetsService(State["SelectedApp"].ToString());
            service.setUserCredentials(username, password);

            //get all spreadsheets
            Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();

            SpreadsheetFeed feed = service.Query(query);

            bool found_spreadsheet = false;
            Hashtable tables = new Hashtable();
            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                string spreadsheet_name = entry.Title.Text;
                if (spreadsheet_name.ToLower() == use_spreadsheet_name.ToLower())
                {
                    //Use this spreadsheet
                    found_spreadsheet = true;
                    AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                    //get all worksheets
                    WorksheetQuery wk_query = new WorksheetQuery(link.HRef.ToString());
                    WorksheetFeed wk_feed = service.Query(wk_query);

                    foreach (WorksheetEntry worksheet in wk_feed.Entries)
                    {
                        string table_name = worksheet.Title.Text;

                        AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                        ListQuery list_query = new ListQuery(listFeedLink.HRef.ToString());
                        ListFeed list_feed = service.Query(list_query);

                        //get field names
                        if (list_feed.Entries.Count == 0)
                        {
                            return "The worksheet " + table_name + " has no values.";
                        }

                        ListEntry fieldRow = (ListEntry)list_feed.Entries[0];
                        ArrayList field_list = new ArrayList();
                        foreach (ListEntry.Custom column in fieldRow.Elements)
                        {
                            Hashtable field = new Hashtable();
                            field["name"] = column.LocalName;
                            field_list.Add(field);
                        }
                        tables[table_name] = field_list;
                    }
                    break;
                }
            }
            if (!found_spreadsheet)
            {
                return use_spreadsheet_name + " could not be found";
            }

            Util util = new Util();
            string connection_string = "spreadsheet=" + use_spreadsheet_name + ";username="******";password="******"DBConnectionString"] = connection_string;
            util.SaveDatabaseSchema(State, "GoogleDocs", connection_string, tables);

            return "OK";
        }
        catch (Exception ex)
        {
            Util util = new Util();
            util.LogError(State, ex);
            if (ex.Message.Contains("Execution of request failed"))
                return "Credentials to your Google Docs Account or spreadsheet name are not valid.";
            else
                return "There was an internal error with access to your Google Docs account.";
        }
    }
        //Fetch all worksheets for given Spreadsheet
        public static ArrayList getWorksheetList(string userName, string passWord, string spreadSheetName)
        {
            ArrayList worksheetList = new ArrayList();

            SpreadsheetsService service = new SpreadsheetsService(spreadSheetName + "Service");

            //You could set it up from DB or config file also. This is not a reccomended way. Just an easy way to show fetching
            service.setUserCredentials(userName, passWord);

            SpreadsheetQuery query = new SpreadsheetQuery();

            SpreadsheetFeed feed = service.Query(query);

            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                if (entry.Title.Text == spreadSheetName)
                {
                    AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                    WorksheetQuery wquery = new WorksheetQuery(link.HRef.ToString());
                    WorksheetFeed wfeed = service.Query(wquery);

                    foreach (WorksheetEntry worksheet in wfeed.Entries)
                    {
                        worksheetList.Add(worksheet.Title.Text);
                    }
                }
            }

            return worksheetList;
        }
Beispiel #30
-1
        public ActionResult MySpreadsheets()
        {
            SpreadsheetsService service = new SpreadsheetsService("chavp-mybook-1");
            service.setUserCredentials("iuityuj@rtrtey5e6yrty", "sdfdsfsdfsdf");

            WorksheetQuery query = new WorksheetQuery("0AsqxIqqTdYVidExTN0R0THh6XzlBa01pOURWVGRSMGc", "private", "full");
            WorksheetFeed feed = service.Query(query);

            List<Row> listData = new List<Row>();

            foreach (WorksheetEntry worksheet in feed.Entries)
            {
                AtomLink cellFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, AtomLink.ATOM_TYPE);

                CellQuery cellQuery = new CellQuery(cellFeedLink.HRef.ToString());
                CellFeed cellFeed = service.Query(cellQuery);

                foreach (CellEntry curCell in cellFeed.Entries)
                {
                    Cell cell = new Cell { Row = curCell.Cell.Row, Index = curCell.Cell.Column, Data = curCell.Cell.Value };

                    var row = listData.Find(r => r.Index == curCell.Cell.Row);
                    if (row == null)
                    {
                        row = new Row { Index = curCell.Cell.Row };
                        listData.Add(row);
                    }

                    row.CellList.Add(cell);
                }
            }

            return View();
        }