예제 #1
1
        public override void Log(LoggingEntery LE)
        {
            IniFile Ini = new IniFile(Path.Combine(Environment.CurrentDirectory, "GoogleDocs.ini"));

            // nir start
                  ////////////////////////////////////////////////////////////////////////////
              // STEP 1: Configure how to perform OAuth 2.0
              ////////////////////////////////////////////////////////////////////////////

              // TODO: Update the following information with that obtained from
              // https://code.google.com/apis/console. After registering
              // your application, these will be provided for you.

              //string CLIENT_ID = "339569043085-6k0io9kdubi7a3g3jes4m76t614fkccr.apps.googleusercontent.com";

              // This is the OAuth 2.0 Client Secret retrieved
              // above.  Be sure to store this value securely.  Leaking this
              // value would enable others to act on behalf of your application!
              //string CLIENT_SECRET = "wWC4Wcb12RbQg4YuGWJtkh4j";

              // Space separated list of scopes for which to request access.
              //string SCOPE = "https://spreadsheets.google.com/feeds https://docs.google.com/feeds";

              // This is the Redirect URI for installed applications.
              // If you are building a web application, you have to set your
              // Redirect URI at https://code.google.com/apis/console.
              //tring REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";

              ////////////////////////////////////////////////////////////////////////////
              // STEP 2: Set up the OAuth 2.0 object
              ////////////////////////////////////////////////////////////////////////////

              // OAuth2Parameters holds all the parameters related to OAuth 2.0.
              OAuth2Parameters parameters = new OAuth2Parameters();

              // Set your OAuth 2.0 Client Id (which you can register at
              // https://code.google.com/apis/console).
              parameters.ClientId = Ini.IniReadValue(ConnectSection,"ClientID");

              // Set your OAuth 2.0 Client Secret, which can be obtained at
              // https://code.google.com/apis/console.
              parameters.ClientSecret = Ini.IniReadValue(ConnectSection,"ClientSecret");

              // Set your Redirect URI, which can be registered at
              // https://code.google.com/apis/console.
              parameters.RedirectUri = Ini.IniReadValue(ConnectSection,"RedirectURI");

              // Set your refresh token
              parameters.RefreshToken = Ini.IniReadValue(ConnectSection,"RefreshToken");
              parameters.AccessToken = Ini.IniReadValue(ConnectSection,"LastAccessToken");

              // Set the scope for this particular service.
              parameters.Scope = Ini.IniReadValue(ConnectSection,"Scope");

              // Get the authorization url.  The user of your application must visit
              // this url in order to authorize with Google.  If you are building a
              // browser-based application, you can redirect the user to the authorization
              // url.
               //string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
              //Console.WriteLine(authorizationUrl);
              //Console.WriteLine("Please visit the URL above to authorize your OAuth "
              //  + "request token.  Once that is complete, type in your access code to "
              //  + "continue...");

              ////////////////////////////////////////////////////////////////////////////
              // STEP 4: Get the Access Token
              ////////////////////////////////////////////////////////////////////////////

              // Once the user authorizes with Google, the request token can be exchanged
              // for a long-lived access token.  If you are building a browser-based
              // application, you should parse the incoming request token from the url and
              // set it in OAuthParameters before calling GetAccessToken().
              OAuthUtil.RefreshAccessToken(parameters);//parameters.AccessToken;
              Ini.IniWriteValue(ConnectSection,"LastAccessToken",parameters.AccessToken);
              // Console.WriteLine("OAuth Access Token: " + accessToken);

              ////////////////////////////////////////////////////////////////////////////
              // STEP 5: Make an OAuth authorized request to Google
              ////////////////////////////////////////////////////////////////////////////

              // Initialize the variables needed to make the request
              GOAuth2RequestFactory requestFactory =
              new GOAuth2RequestFactory(null, "OctoTipPlus", parameters);
              SpreadsheetsService myService = new SpreadsheetsService("OctoTipPlus");
              myService.RequestFactory = requestFactory;
            // nir end

            string User = Ini.IniReadValue("UserLogin","User");
            string Password = Ini.IniReadValue("UserLogin","Password");

            //	SpreadsheetsService myService = new SpreadsheetsService("MySpreadsheetIntegration-v1");
            //myService.setUserCredentials(User,Password);

            SpreadsheetQuery Squery = new SpreadsheetQuery();
            string Sender = LE.Sender;
            Squery.Title = Sender;
            Squery.Exact = true;
            SpreadsheetFeed Sfeed;
            try
            {
                Sfeed = myService.Query(Squery);
            }
            catch (Google.GData.Client.InvalidCredentialsException e)
            {
                throw(new Exception(string.Format("Credentials error in google acount for user:{0}",User),e));
            }

            if(Sfeed.Entries.Count == 0)
            {
                //DriveService service1 = new DriveService();

             	//service.SetAuthenticationToken(parameters.AccessToken);//.setUserCredentials(User,Password);
                //Google.GData.Client.GOAuth2RequestFactory requestf =  new Google.GData.Client.GOAuth2RequestFactory(null, "OctoTipPlus",parameters);
                OAuthUtil.RefreshAccessToken(parameters);//parameters.AccessToken;
              			Ini.IniWriteValue(ConnectSection,"LastAccessToken",parameters.AccessToken);
                Google.GData.Documents.DocumentsService service = new Google.GData.Documents.DocumentsService("OctoTipPlus");
                GOAuth2RequestFactory requestFactory2 =
              				new GOAuth2RequestFactory(null, "OctoTipPlus", parameters);
                service.RequestFactory = requestFactory2;
                //service.RequestFactory=requestf;
                // Instantiate a DocumentEntry object to be inserted.
                Google.GData.Documents.DocumentEntry entry = new Google.GData.Documents.DocumentEntry();

                // Set the document title
                entry.Title.Text = LE.Sender;

                // Add the document category
                entry.Categories.Add(Google.GData.Documents.DocumentEntry.SPREADSHEET_CATEGORY);

                // Make a request to the API and create the document.
                Google.GData.Documents.DocumentEntry newEntry = service.Insert(
                    Google.GData.Documents.DocumentsListQuery.documentsBaseUri, entry);

                Squery = new SpreadsheetQuery();
                Squery.Title = Sender;
                Squery.Exact = true;
                Sfeed = myService.Query(Squery);

            }

            SpreadsheetEntry spreadsheet = (SpreadsheetEntry)Sfeed.Entries[0];

            WorksheetEntry ProtocolWorksheetEntry=null;

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

            WorksheetQuery Wquery = new WorksheetQuery(link.HRef.ToString());
            WorksheetFeed Wfeed = myService.Query(Wquery);

            foreach (WorksheetEntry worksheet in Wfeed.Entries)
            {
                if (worksheet.Title.Text==LE.SubSender)
                {
                    ProtocolWorksheetEntry = worksheet;
                }
            }

            if (ProtocolWorksheetEntry==null)
            {
                // cteate new worksheet
                WorksheetEntry worksheet = new WorksheetEntry();
                worksheet.Title.Text = LE.SubSender;
                worksheet.Cols = 3;
                worksheet.Rows = 5;

                // Send the local representation of the worksheet to the API for
                // creation.  The URL to use here is the worksheet feed URL of our
                // spreadsheet.
                WorksheetFeed wsFeed = spreadsheet.Worksheets;
                ProtocolWorksheetEntry = myService.Insert(wsFeed, worksheet);

                CellFeed cellFeed= ProtocolWorksheetEntry.QueryCellFeed();

                CellEntry cellEntry= new CellEntry (1, 1,DateHeader);
                cellFeed.Insert(cellEntry);
                cellEntry= new CellEntry (1, 2, MessageHeader);
                cellFeed.Insert(cellEntry);

            }

            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = ProtocolWorksheetEntry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed listFeed = myService.Query(listQuery);

            string Message = string.Format("{0}\n{1}",LE.Title,LE.Message);

            // Create a local representation of the new row.
            ListEntry row = new ListEntry();
            row.Elements.Add(new ListEntry.Custom() { LocalName = DateHeader, Value = DateTime.Now.ToString() });
            row.Elements.Add(new ListEntry.Custom() { LocalName = MessageHeader, Value = Message });

            // Send the new row to the API for insertion.
            myService.Insert(listFeed, row);
        }
예제 #2
0
        private static ListEntry InsertRow(SpreadsheetsService service, WorksheetEntry entry, NameValueCollection parameters)
        {
            logger.Debug("inserting row...");
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());

            ListFeed feed = service.Query(query);

            ListEntry newRow = new ListEntry();
            foreach(string key in parameters)
            {
                ListEntry.Custom curElement = new ListEntry.Custom();
                curElement.Value = parameters[key];
                curElement.LocalName = key;
                newRow.Elements.Add(curElement);
            }

            // add datetime
            ListEntry.Custom el = new ListEntry.Custom();
            el.Value = parameters["data"];
            el.LocalName = DateTime.Now.ToString() ;
            newRow.Elements.Add(el);

            ListEntry insertedRow = feed.Insert(newRow);
            return insertedRow;
        }
 private string GetCellText(ListEntry row, ColumnHeader column)
 {
     if(null == row.Elements[(int)column])
     {
         return "";
     }
     return row.Elements[(int)column].Value;
 }
 public ListEntry GetBadCardEntry(BoardStatsAnalysis boardStatsAnalysis)
 {
     var errorRow = new ListEntry();
     errorRow.Elements.Add(new ListEntry.Custom() { LocalName = "startdate", Value = boardStatsAnalysis.FirstStartDate.ToString() });
     errorRow.Elements.Add(new ListEntry.Custom() { LocalName = "enddate", Value = "" });
     errorRow.Elements.Add(new ListEntry.Custom() { LocalName = "headline", Value = "Unproccessed Trello Cards" });
     errorRow.Elements.Add(new ListEntry.Custom() { LocalName = "text", Value = GetSummaryTextForErrorCards(boardStatsAnalysis) });
     return errorRow;
 }
 public ListEntry GetTitleCardEntry(BoardStatsAnalysis boardStatsAnalysis)
 {
     var titleRow = new ListEntry();
     titleRow.Elements.Add(new ListEntry.Custom() { LocalName = "startdate", Value = boardStatsAnalysis.FirstStartDate.ToString() });
     titleRow.Elements.Add(new ListEntry.Custom() { LocalName = "enddate", Value = "" });
     titleRow.Elements.Add(new ListEntry.Custom() { LocalName = "headline", Value = "Development Timeline" });
     titleRow.Elements.Add(new ListEntry.Custom() { LocalName = "text", Value = _htmlFactory.GetSummaryTextForBoardStat(boardStatsAnalysis) });
     titleRow.Elements.Add(new ListEntry.Custom() { LocalName = "type", Value = "title" });
     return titleRow;
 }
        public ListEntry GetCompletedCardEntry(CardStats cardStat, TimeSpan timeOffset)
        {
            var row = new ListEntry();
            row.Elements.Add(new ListEntry.Custom() { LocalName = "startdate", Value = cardStat.DoneAction.DateInTimeZone(_configuration.TimeZone).Add(timeOffset).ToString() });
            row.Elements.Add(new ListEntry.Custom() { LocalName = "enddate", Value = "" });
            row.Elements.Add(new ListEntry.Custom() { LocalName = "headline", Value = GetHeadlineForCard(cardStat) });
            row.Elements.Add(new ListEntry.Custom() { LocalName = "text", Value = String.Format("{0} Elapsed Day(s)", cardStat.BusinessDaysElapsed) });
            row.Elements.Add(new ListEntry.Custom() { LocalName = "media", Value = cardStat.CardData.Card.Url });
            row.Elements.Add(new ListEntry.Custom() { LocalName = "tag", Value = GetCategory(cardStat) });

            return row;
        }
예제 #7
0
        private static void PopulateRow(MarketStatTypesBySolarSystem[] marketStatTypes, ListEntry.Custom[,] listEntries, int rowIndex, invType invType)
        {
            int baseColumnIndex = 0;
            for (int solarSystemCounter = 0; solarSystemCounter < marketStatTypes.Length; solarSystemCounter++)
            {
                mapSolarSystem mapSolarSystem = marketStatTypes[solarSystemCounter].MapSolarSystem;
                // for typeId, SolarSystemId, get Buy and Sell
                MarketStatType marketStatType = null;
                if (invType != null)
                {
                    marketStatType = marketStatTypes[solarSystemCounter].MarketStatTypes.Where(m => m.Id == invType.typeID).FirstOrDefault();
                }

                listEntries[rowIndex, baseColumnIndex + 1] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Buy Min", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Buy.Min.ToString() : string.Empty,
                };
                listEntries[rowIndex, baseColumnIndex + 2] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Buy Avg", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Buy.Avg.ToString() : string.Empty,
                };
                listEntries[rowIndex, baseColumnIndex + 3] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Buy Max", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Buy.Max.ToString() : string.Empty,
                };

                listEntries[rowIndex, baseColumnIndex + 4] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Sell Min", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Sell.Min.ToString() : string.Empty,
                };
                listEntries[rowIndex, baseColumnIndex + 5] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Sell Avg", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Sell.Avg.ToString() : string.Empty,
                };
                listEntries[rowIndex, baseColumnIndex + 6] = new ListEntry.Custom()
                {
                    LocalName = string.Format("{0} Sell Max", mapSolarSystem.solarSystemName),
                    Value = marketStatType != null ? marketStatType.Sell.Max.ToString() : string.Empty,
                };

                baseColumnIndex += 6;
            }
        }
        public void PopulateNewWorksheet(OAuth2ClientCredentials clientCredentials, string refreshToken, string spreadsheetTitle, string worksheetTitle, ListEntry.Custom[,] listEntries)
        {
            SpreadsheetsService service = GetSpreadsheetService(clientCredentials, refreshToken);

            SpreadsheetQuery query = new SpreadsheetQuery()
            {
                Title = spreadsheetTitle,
            };
            SpreadsheetFeed feed = service.Query(query);

            if (feed.Entries.Count == 0)
                throw new SpreadsheetNotFoundException(string.Format("Spreadsheet with title {0} not found", spreadsheetTitle));

            WorksheetEntry worksheet = CreateWorksheet(worksheetTitle, (uint)listEntries.GetLength(0), (uint)listEntries.GetLength(1), service, feed);

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

            for (int i = 0; i < listEntries.GetLength(1); i++)
            {
                CellEntry cellEntry = new CellEntry(1, (uint)i + 1, listEntries[0, i].LocalName);
                service.Insert(cellFeed, cellEntry);
            }

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

            for (int i = 1; i < listEntries.GetLength(0); i++)
            {
                ListEntry row = new ListEntry();
                for (int j = 0; j < listEntries.GetLength(1); j++)
                {
                    if (listEntries[i, j] != null)
                    {
                        listEntries[i, j].LocalName = listEntries[i, j].LocalName.ToLower().Replace(" ","");
                        row.Elements.Add(listEntries[i, j]);
                    }
                }
                LoggerUtil.LogMessage(string.Format("Adding row for {0}", listEntries[i, 0].Value));
                service.Insert(listFeed, row);
            }
        }
예제 #9
0
 private ListEntry GenerateCourseRow(Course course)
 {
     ListEntry row = new ListEntry();
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderTitle, Value = course.Title });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderAuthor, Value = course.Author });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderLevel, Value = course.Level });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderDuration, Value = course.Duration.ToString() });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderRelease, Value = course.ReleaseDate.ToShortDateString() });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderStatus, Value = course.LearningStatus.ToString() });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderCommment, Value = course.Comment });
     return row;
 }
예제 #10
0
        /// <summary>
        /// Updates the value of a cell in a single worksheet row.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the ListEntry representing the row to update</param>
        /// <returns>the updated ListEntry object</returns>
        private static ListEntry UpdateRow(SpreadsheetsService service, ListEntry entry)
        {
            ListEntry.Custom firstColumn = entry.Elements[0];

            Console.WriteLine();
            Console.Write("Enter a new value for \"{0}\" (currently \"{1}\"): ",
                firstColumn.LocalName, firstColumn.Value);
            String newValue = Console.ReadLine();

            firstColumn.Value = newValue;

            ListEntry updatedRow = entry.Update() as ListEntry;

            Console.WriteLine("Successfully updated \"{0}\": \"{1}\"",
                updatedRow.Elements[0].LocalName, updatedRow.Elements[0].Value);

            return updatedRow;
        }
예제 #11
0
 private ListEntry GenerateCategoryRow(string categoryName, int coursesInCategory)
 {
     ListEntry row = new ListEntry();
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderTitle, Value = categoryName });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderAuthor, Value = coursesInCategory.ToString() + " Courses" });
     return row;
 }
예제 #12
0
        public int loadSpellLogFromRoster()
        {
            int spellsAdded = 0;
            try {
                ListFeed listFeed = GDriveManager.getListFeed(spreadsheet, SPELL_LOG_WS);

                string sql = "SELECT * FROM (SELECT DISTINCT r.name, r.class, s.spells, s.level, s.priority FROM roster AS r, spell_template AS s WHERE r.active = 'Yes' AND r.class = s.class) AS tmp WHERE NOT EXISTS(SELECT 1 FROM spell_log AS sl WHERE sl.name = tmp.name AND sl.spells = tmp.spells AND sl.class = tmp.class)";

                DbDataReader rs = DBManager.getManager().executeQuery(sql);

                while (rs.Read()) {
                    string name = rs[0].ToString().Trim();
                    string className = rs[1].ToString().Trim();
                    string spells = rs[2].ToString().Trim();
                    string level = rs[3].ToString().Trim();
                    string priority = rs[4].ToString().Trim();
                    ListEntry row = new ListEntry();

                    row.Elements.Add(new ListEntry.Custom() { LocalName = "name", Value = name });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "class", Value = className });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "spells", Value = spells });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "level", Value = level });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "priority", Value = priority });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "hasspell", Value = "" });

                    logger.Info(String.Format("Inserting spell entry. [{0}, {1}, {2}, {3}, {4}]", name, className, spells, level, priority));

                    // Send the new row to the API for insertion.
                    GDriveManager.getService().Insert(listFeed, row);

                    spellsAdded++;
                }

                loadSpellLog();

            } catch (Exception e) {
                logger.Error("Failed to insert spell entry", e);
                throw e;
            }

            return spellsAdded;
        }
예제 #13
0
        /// <summary>
        /// Inserts a new row in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet into which the row will be inserted</param>
        /// <returns>the inserted ListEntry object, representing the new row</returns>
        private static ListEntry InsertRow(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed feed = service.Query(query);

            ListEntry firstRow = feed.Entries[0] as ListEntry;
            ListEntry newRow = new ListEntry();

            Console.WriteLine();
            Console.WriteLine("Inserting a new row...");
            foreach (ListEntry.Custom element in firstRow.Elements)
                {
                Console.Write("Enter the value of column \"{0}\": ", element.LocalName);
                String elementValue = Console.ReadLine();

                ListEntry.Custom curElement = new ListEntry.Custom();
                curElement.LocalName = element.LocalName;
                curElement.Value = elementValue;

                newRow.Elements.Add(curElement);
            }

            ListEntry insertedRow = feed.Insert(newRow); 
            Console.WriteLine("Successfully inserted new row: \"{0}\"",
                insertedRow.Content.Content);

            return insertedRow;
        }
        private ListEntry MountWorksheetRow(Card card, Dictionary<string, DateTime> sprintPeriod)
        {
            var row = new ListEntry();
            var title = _cardHelper.GetCardTitle(card);
            var priority = _cardHelper.GetCardPriority(card);
            var importance = _cardHelper.GetImportance(priority);
            var urgency = _cardHelper.GetUrgency(priority);
            var estimate = _cardHelper.GetCardEstimate(card);
            var labels = _cardHelper.GetCardLabels(card);
            var status = _cardHelper.GetStatus(card);
            var responsible = ExecutionHelper.ExecuteAndRetryOnFail(() => _cardHelper.GetResponsible(card));
            var comments = ExecutionHelper.ExecuteAndRetryOnFail(() => _cardHelper.GetCardComments(card));
            var workedAndPending = ExecutionHelper.ExecuteAndRetryOnFail(() => _cardHelper.GetWorkedAndPending(estimate, comments, sprintPeriod["endDate"]));
            var workedAndPendingInSprint = ExecutionHelper.ExecuteAndRetryOnFail(() => _cardHelper.GetWorkedAndPending(estimate, comments, sprintPeriod["startDate"], sprintPeriod["endDate"]));
            var worked = workedAndPending["worked"].ToString(CultureInfo.InvariantCulture).Replace(".", ",");
            var workedInSprint = workedAndPendingInSprint["worked"].ToString(CultureInfo.InvariantCulture).Replace(".", ",");
            var pending = workedAndPending["pending"].ToString(CultureInfo.InvariantCulture).Replace(".", ",");
            var reassessment = (workedAndPending["worked"] + workedAndPending["pending"]).ToString(CultureInfo.InvariantCulture).Replace(".", ",");

            row.Elements.Add(new ListEntry.Custom { LocalName = "status", Value = status });
            row.Elements.Add(new ListEntry.Custom { LocalName = "titulo", Value = title });
            row.Elements.Add(new ListEntry.Custom { LocalName = "responsaveis", Value = responsible });
            row.Elements.Add(new ListEntry.Custom { LocalName = "importancia", Value = importance });
            row.Elements.Add(new ListEntry.Custom { LocalName = "urgencia", Value = urgency });
            row.Elements.Add(new ListEntry.Custom { LocalName = "estimativa", Value = estimate });
            row.Elements.Add(new ListEntry.Custom { LocalName = "trabalhado", Value = worked });
            row.Elements.Add(new ListEntry.Custom { LocalName = "trabalhadonosprint", Value = workedInSprint });
            row.Elements.Add(new ListEntry.Custom { LocalName = "restante", Value = pending });
            row.Elements.Add(new ListEntry.Custom { LocalName = "reestimativa", Value = reassessment });
            row.Elements.Add(new ListEntry.Custom { LocalName = "rotulos", Value = labels });
            row.Elements.Add(new ListEntry.Custom { LocalName = "link", Value = card.ShortUrl });

            return row;
        }
예제 #15
0
        private TaskMain GetRowElements(ListEntry row)
        {
            TaskMain tm = new TaskMain();

            tm.LinkToTracker= row.Feed.Entries.FirstOrDefault().Feed.Links.First().AbsoluteUri.ToString();
            var str = row.Links;
            tm.TaskID = row.Elements[0].Value;
            if (tm.TaskID == "")
                tm.TaskID = row.Elements[1].Value;
            tm.Description = row.Elements[3].Value;
            tm.Status = row.Elements[5].Value;
            tm.Comments = row.Elements[6].Value;
            tm.Source = Sources.GoogleSheets;

            return tm;
        }
        //this methos posts the data to the first workSheet withiin the spreadSheet
        public static void postDataToSameWorkSheet(ExternalSnapshots _externalSnapshots)
        {
            WorksheetFeed wsFeed = spreadSheet.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed listFeed = spreadSheetsService.Query(listQuery);

            ListEntry row;

            foreach (ExternalSnapshot externalSnapshot in _externalSnapshots.resultList)
            {
                foreach (Data dataToPost in externalSnapshot.data)
                {
                    row = new ListEntry();
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "id", Value = dataToPost.id.ToString() });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "type", Value = dataToPost.testType });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "name", Value = dataToPost.name });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "perf", Value = dataToPost.perf.ToString() });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "time", Value = dataToPost.time });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "status", Value = dataToPost.time });
                    row.Elements.Add(new ListEntry.Custom() { LocalName = "location", Value = externalSnapshot.locationShortName });

                    // Send the new row to the API for insertion.
                    row = spreadSheetsService.Insert(listFeed, row); ;

                }
            }
        }
예제 #17
0
        //public void UploadSheet(bool Forcesync, Dictionary<string, Tuple<string, SteamID, string, bool>> Maplist, String IntegrationName, string CLIENT_ID,string CLIENT_SECRET, string REDIRECT_URI, string SCOPE, string GoogleAPI)
        public void UploadSheet(bool Forcesync, Dictionary<string, Tuple<string, string, string, bool>> Maplist, OAuth2Parameters parameters, string IntegrationName, string SpreadSheetURI)
        {
            GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, IntegrationName, parameters);
            SpreadsheetsService service = new SpreadsheetsService(IntegrationName);

            string accessToken = parameters.AccessToken;
            service.RequestFactory = requestFactory;

            WorksheetEntry worksheet = GetWorksheet(parameters, IntegrationName, SpreadSheetURI, service);

            worksheet.Rows = Convert.ToUInt32(Maplist.Count + 2);
            worksheet.Update();

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

            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());

            ListFeed listFeed = service.Query(listQuery);

            int Increments = 1;

            if (listFeed.Entries.Count.ToString() == "1")
            {
                Increments = 0;
            }

            ListEntry NewRow = new ListEntry();

            foreach (var item in Maplist)
            {

                ListEntry row = (ListEntry)listFeed.Entries[Increments];

                row.Elements[1].Value = item.Key;
                row.Elements[2].Value = item.Value.Item1;
                row.Elements[3].Value = item.Value.Item2;
                row.Elements[4].Value = item.Value.Item3;
                row.Elements[5].Value = item.Value.Item4.ToString();

                row.Update();
                //service.Insert(listFeed, row);

                Increments = Increments + 1;
            }

            listFeed.Publish();
        }
예제 #18
0
        private void InsertRow(string pPlayerOne, string pPlayerTwo, string pBetAmount, ListFeed pFeed)
        {
            DateTime tDateTime = DateTime.Today;

            string tDate = tDateTime.Day + "/" + tDateTime.Month + "/" + tDateTime.Year;
            int tBetAmount = ConvertBetToInt(pBetAmount);
            int tCommission = (int)(tBetAmount * 0.10);
            int tAdminFee;
            if (tBuyinMode == true)
            {
                tAdminFee = (int)(tCommission * 0.10);
            }
            else
            {
                tAdminFee = (int)(tCommission * 0.30);
            }

            ListEntry tNewRow = new ListEntry();

            ListEntry.Custom tElementDate = new ListEntry.Custom();
            tElementDate.LocalName = "date";
            tElementDate.Value = tDate;

            ListEntry.Custom tElementPlayer1 = new ListEntry.Custom();
            tElementPlayer1.LocalName = "nameofplayer1";
            tElementPlayer1.Value = pPlayerOne;

            ListEntry.Custom tElementPlayer2 = new ListEntry.Custom();
            tElementPlayer2.LocalName = "nameofplayer2";
            tElementPlayer2.Value = pPlayerTwo;

            ListEntry.Custom tElementPlayer1Bet = new ListEntry.Custom();
            tElementPlayer1Bet.LocalName = "player1bet";
            tElementPlayer1Bet.Value = tBetAmount.ToString();

            ListEntry.Custom tElementPlayer2Bet = new ListEntry.Custom();
            tElementPlayer2Bet.LocalName = "player2bet";
            tElementPlayer2Bet.Value = tBetAmount.ToString();

            ListEntry.Custom tElementCommission = new ListEntry.Custom();
            tElementCommission.LocalName = "commission";
            tElementCommission.Value = tCommission.ToString();

            ListEntry.Custom tElementAdminFee = new ListEntry.Custom();
            tElementAdminFee.LocalName = "commisionforadmin";
            tElementAdminFee.Value = tAdminFee.ToString();

            tNewRow.Elements.Add(tElementAdminFee);
            tNewRow.Elements.Add(tElementCommission);
            tNewRow.Elements.Add(tElementDate);
            tNewRow.Elements.Add(tElementPlayer1);
            tNewRow.Elements.Add(tElementPlayer1Bet);
            tNewRow.Elements.Add(tElementPlayer2);
            tNewRow.Elements.Add(tElementPlayer2Bet);

            var tResult = pFeed.Insert(tNewRow) as ListEntry;
        }
예제 #19
0
        public ListEntry Insert(ListFeed listFeed, ListEntry listEntry)
        {
            Debug.WriteLine("Try ListInsert");

            return Service.Insert(listFeed, listEntry);

            /*
            ListEntry retVal = null;
            try
            {
                retVal = Service.Insert(listFeed, listEntry);
            }
            catch (Google.GData.Client.GDataRequestException ex)
            {
                Debug.WriteLine("ListEntry.Insert fail:" + ex.ToString());
                return null;
            }

            return retVal;*/
        }
 public void InsertInWorksheet(WorksheetEntry worksheet, ListEntry row)
 {
     var listFeed = GetListFeed(worksheet);
     _connection.SpreadsheetService.Insert(listFeed, row);
 }
예제 #21
0
		private void SetNewUserData( string userName, IEnumerable<Hero> heroes )
		{
			if( _currentEntry == null )
			{
				return;
			}

			var newRow = new ListEntry();
			var row = newRow.Elements;

			row.Add( new ListEntry.Custom() { LocalName = Constants.IgnHeader, Value = userName } );

			// set our tier rankings
			row.Add( new ListEntry.Custom() { LocalName = Constants.TierRankingsHeader, Value = GetTierRankings( heroes ) } );

			foreach( var hero in heroes )
			{
				var heroThreatMatrix = new StringBuilder();
				var heroCompatibilityMatrix = new StringBuilder();

				foreach( var threatValue in hero.ThreatMatrix.Values )
				{
					heroThreatMatrix.AppendFormat( "{0}{1}", threatValue, Constants.DelimitingCharacter );
				}

				foreach( var compatibilityValue in hero.CompatibilityMatrix.Values )
				{
					heroCompatibilityMatrix.AppendFormat( "{0}{1}", compatibilityValue, Constants.DelimitingCharacter );
				}

				var threatMatrixName = string.Format( Constants.ThreatMatrixFormatString, hero.HType).ToLower();
				var compMatrixName = string.Format( Constants.CompatibilityMatrixFormatString, hero.HType ).ToLower();

				row.Add( new ListEntry.Custom() { LocalName = threatMatrixName, Value = GetThreatMatrix( hero ) } );
				row.Add( new ListEntry.Custom() { LocalName = compMatrixName, Value = GetCompatibilityMatrix( hero ) } );
			}

			var worksheetFeed = (WorksheetEntry)_currentEntry.Worksheets.Entries[0];

			var listFeedLink = worksheetFeed.Links.FindService( GDataSpreadsheetsNameTable.ListRel, null );
			var listQuery = new ListQuery( listFeedLink.HRef.ToString() );
			var listFeed = _spreadsheetsService.Query( listQuery );

			_spreadsheetsService.Insert( listFeed, newRow );
		}
예제 #22
0
        private static ListEntry MountWorksheetRow(CardWorkDto cardWork)
        {
            var cultureInfoPtBr = new CultureInfo("pt-BR", false);
            var row = new ListEntry();

            row.Elements.Add(new ListEntry.Custom { LocalName = "profissional", Value = cardWork.Professional });
            row.Elements.Add(new ListEntry.Custom { LocalName = "cartao", Value = cardWork.CardName });
            row.Elements.Add(new ListEntry.Custom { LocalName = "linkcartao", Value = cardWork.CardLink });
            row.Elements.Add(new ListEntry.Custom { LocalName = "datacomentario", Value = cardWork.CommentAt.ToHumanReadable() });
            row.Elements.Add(new ListEntry.Custom { LocalName = "datahoratrabalho", Value = cardWork.WorkAt.ToHumanReadable() });
            row.Elements.Add(new ListEntry.Custom { LocalName = "trabalhado", Value = cardWork.Worked.ToString(cultureInfoPtBr) });
            row.Elements.Add(new ListEntry.Custom { LocalName = "comentario", Value = cardWork.Comment });

            return row;
        }
예제 #23
0
 private ListEntry GenerateEmptyRow()
 {
     ListEntry row = new ListEntry();
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderTitle, Value = " " });
     return row;
 }
        public void quickAdditions(WorksheetEntry workSheet, String columnName, List<FileInfo> files)
        {
            if (files.Count == 0)
            {
                return;
            }
            AtomLink listFeedLink = workSheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed listFeed = service.Query(listQuery);
            ListEntry row = new ListEntry();

            foreach (FileInfo file in files)
            {
                row.Elements.Add(new ListEntry.Custom() { LocalName = columnName.ToLower(), Value = System.IO.Path.GetFileNameWithoutExtension(file.Name)});
                
            }

            service.Insert(listFeed, row);
        }
예제 #25
0
 private ListEntry GenerateRow(string titleField, string authorField = "", string levelField = "", string durationField = "", string releaseField = "", string statusField = "", string commentField = "")
 {
     ListEntry row = new ListEntry();
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderTitle, Value = titleField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderAuthor, Value = authorField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderLevel, Value = levelField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderDuration, Value = durationField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderRelease, Value = releaseField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderStatus, Value = statusField });
     row.Elements.Add(new ListEntry.Custom() { LocalName = HeaderCommment, Value = commentField });
     return row;
 }
        //Post data to Google Docs
        //Worksheets names within speadsheet have been set to the monitor names
        //Monitor name will be used to identify worksheet within which to post data.
        public static bool postDataWorkSheetByMonitor(ExternalSnapshots _externalSnapshots)
        {
            IDictionary<string, ListFeed> workSheetList = new Dictionary<string, ListFeed>();
            WorksheetFeed wsFeed = spreadSheet.Worksheets;
            AtomLink listFeedLink1;
            ListQuery listQuery1;
            ListFeed listFeed1;

            try
            {

                // loop on worksheets
                // Fetch the list feed of the worksheet.
                // The listfeed is required to post data to the worksheet
                // create collection of key/value pairs where the key is the worksheet name and the value is the listfeed for the worksheet
                foreach (WorksheetEntry ws in wsFeed.Entries)
                {

                    listFeedLink1 = ws.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
                    listQuery1 = new ListQuery(listFeedLink1.HRef.ToString());
                    listFeed1 = spreadSheetsService.Query(listQuery1);

                    workSheetList.Add(ws.Title.Text, listFeed1);
                }

                //row to post
                ListEntry row;

                //loop on the externalSnapshots.
                //each entry within the reultList will be used to compose a row for posting to the Goolge spreadsheet
                foreach (ExternalSnapshot externalSnapshot in _externalSnapshots.resultList)
                {
                    foreach (Data dataToPost in externalSnapshot.data)
                    {
                        row = new ListEntry();
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "id", Value = dataToPost.id.ToString() });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "type", Value = dataToPost.testType });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "name", Value = dataToPost.name });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "perf", Value = dataToPost.perf.ToString() });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "time", Value = dataToPost.time });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "status", Value = dataToPost.time });
                        row.Elements.Add(new ListEntry.Custom() { LocalName = "location", Value = externalSnapshot.locationShortName });

                        // Send the new row to the Google Spreadsheets API for insertion.
                        row = spreadSheetsService.Insert(workSheetList[dataToPost.name], row); ;

                    }
                }

            }
            catch (Exception _exception)
            {
                MessageBox.Show(_exception.Message);
                return false;
            }

            return true;
        }
예제 #27
0
        public void insertNewLootEntry(string date, string name, string eventName, string item, string slot, string rot, string altLoot)
        {
            try {
                // Create a local representation of the new row.
                ListEntry row = new ListEntry();
                row.Elements.Add(new ListEntry.Custom() { LocalName = "date", Value = date });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "name", Value = name });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "event", Value = eventName });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "item", Value = item });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "slot", Value = slot });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "rot", Value = rot });
                row.Elements.Add(new ListEntry.Custom() { LocalName = "altloot", Value = altLoot });

                // Send the new row to the API for insertion.
                GDriveManager.getService().Insert(logFeed, row);

                logger.Info(String.Format("Inserted loot entry. [{0}, {1}, {2}, {3}, {4}, {5}, {6}]", date, name, eventName, item, slot, rot, altLoot));
            } catch (Exception e) {
                logger.Error(String.Format("Failed to insert loot entry [{0}, {1}, {2}, {3}, {4}, {5}, {6}]", date, name, eventName, item, slot, rot, altLoot), e);
                throw e;
            }
        }
예제 #28
0
        /// <summary>
        /// Converts the gsx: tags to a comma seperated list for parsing
        /// Warning: Not robust for handling formulas
        /// </summary>
        /// <param name="entry">The list entry</param>
        /// <returns>The gsx: tags as a comma separated list</returns>
        private String ToCommaSeparatedString(ListEntry entry)
        {
            if (entry != null) 
            {
                String commaSeparated = "";
   
                ListEntry.CustomElementCollection elements = entry.Elements;
                for (int i=0; i < elements.Count; i++)
                {
                    commaSeparated += elements[i].LocalName + "=" + elements[i].Value + ",";
                }

                return commaSeparated.Substring(0, commaSeparated.Length - 1);
            }
            return ""; 
        }
 public void PopulateNewWorksheet(Library.DataContracts.OAuth2ClientCredentials clientCredentials, string refreshToken, string spreadsheetTitle, string worksheetTitle, ListEntry.Custom[,] listEntries)
 {
 }
예제 #30
0
        private void DoListInsert()
        {
            String[] commaSplit = this.listAddTextBox.Text.Split(',');
            ListEntry entry = new ListEntry();

            for (int i=0; i < commaSplit.Length; i++)
            {
                String[] pair = commaSplit[i].Split('=');
                ListEntry.Custom custom = new ListEntry.Custom();
                custom.LocalName = pair[0];
                custom.Value = pair[1];
                entry.Elements.Add(custom);
            }

            AtomEntry retEntry = service.Insert(new Uri(this.worksheetListView.SelectedItems[0].SubItems[2].Text), entry);
        }