private void RefreshIfDirty() { if (!IsDirty() && _cache != null) return; _cache = null; SettingsCache cache = new SettingsCache(); try { string solutionFile = SelectionContext.SolutionFilename; if (string.IsNullOrEmpty(solutionFile)) return; GitItem item = StatusCache[solutionFile]; if (item == null) return; cache.SolutionFilename = item.FullPath; cache.SolutionCookie = item.ChangeCookie; if (!item.Exists) return; GitWorkingCopy wc = item.WorkingCopy; GitItem parent; if (wc != null) parent = StatusCache[wc.FullPath]; else parent = item.Parent; if (parent != null) { cache.ProjectRoot = parent.FullPath; cache.ProjectRootItem = parent; } if (cache.ProjectRoot != null) { parent = StatusCache[cache.ProjectRoot]; if (parent == null) return; cache.ProjectRootItem = parent; cache.RootCookie = parent.ChangeCookie; } } finally { _cache = cache; } }
void SetProjectRootValue(string value) { if (SolutionFilename == null) return; string sd = GitTools.GetRepositoryPath(GitTools.GetNormalizedDirectoryName(SolutionFilename).TrimEnd('\\') + '\\'); string v = GitTools.GetRepositoryPath(GitTools.GetNormalizedFullPath(value)).ToString(); if (!v.EndsWith("/")) v += "/"; if (!sd.StartsWith(v, FileSystemUtil.StringComparison)) return; GetService<IFileStatusCache>().MarkDirty(SolutionFilename); _cache = null; }
void SetProjectRootValue(string value) { if (SolutionFilename == null) return; string sd = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedDirectoryName(SolutionFilename).TrimEnd('\\') + '\\').ToString(); string v = SvnTools.PathToRelativeUri(SvnTools.GetNormalizedFullPath(value)).ToString(); if (!v.EndsWith("/")) v += "/"; if (!sd.StartsWith(v, StringComparison.OrdinalIgnoreCase)) return; Uri solUri; Uri resUri; if (!Uri.TryCreate("file:///" + sd.Replace('\\', '/'), UriKind.Absolute, out solUri) || !Uri.TryCreate("file:///" + v.Replace('\\', '/'), UriKind.Absolute, out resUri)) return; using (SvnClient client = GetService<ISvnClientPool>().GetNoUIClient()) { SvnSetPropertyArgs ps = new SvnSetPropertyArgs(); ps.ThrowOnError = false; client.SetProperty(SolutionFilename, AnkhSccPropertyNames.ProjectRoot, solUri.MakeRelativeUri(resUri).ToString(), ps); GetService<IFileStatusCache>().MarkDirty(SolutionFilename); // The getter will reload the settings for us } _cache = null; }
private void SetProjectRootViaProperty(SettingsCache cache, string value) { string dir = value; string solutionFile = cache.SolutionFilename; SvnItem directory = StatusCache[solutionFile].Parent; if (directory == null) return; SvnWorkingCopy wc = directory.WorkingCopy; int up = 0; while (dir.StartsWith("../")) { up++; dir = dir.Substring(3); if (directory != null) directory = directory.Parent; } if (directory == null) return; // Invalid value if (directory.WorkingCopy != wc) return; // Outside workingcopy if (dir.Length == 0) { cache.ProjectRoot = directory.FullPath; cache.ProjectRootUri = directory.Uri; } }
private void LoadPropertyBoth(SettingsCache cache, SvnPropertyValue pv) { bool boolValue; int intValue; switch (pv.Key) { case SvnPropertyNames.BugTrackAppend: if (!cache.BugTrackAppend.HasValue && TryParseBool(pv, out boolValue)) cache.BugTrackAppend = boolValue; break; case SvnPropertyNames.BugTrackLabel: if (cache.BugTrackLabel == null) cache.BugTrackLabel = pv.StringValue; break; case SvnPropertyNames.BugTrackLogRegex: if (cache.BugTrackLogRegexes == null) cache.BugTrackLogRegexes = pv.StringValue; break; case SvnPropertyNames.BugTrackMessage: if (cache.BugTrackMessage == null) cache.BugTrackMessage = pv.StringValue.Replace("\r", ""); break; case SvnPropertyNames.BugTrackNumber: if (!cache.BugTrackNumber.HasValue && TryParseBool(pv, out boolValue)) cache.BugTrackNumber = boolValue; break; case SvnPropertyNames.BugTrackUrl: if (cache.BugTrackUrl == null) cache.BugTrackUrl = pv.StringValue; break; case SvnPropertyNames.BugTrackWarnIfNoIssue: if (!cache.BugTrackWarnIfNoIssue.HasValue && TryParseBool(pv, out boolValue)) cache.BugTrackWarnIfNoIssue = boolValue; break; case SvnPropertyNames.TortoiseSvnLogMinSize: if (!cache.LogMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue) && int.TryParse(pv.StringValue, out intValue)) { cache.LogMessageMinSize = intValue; } break; case SvnPropertyNames.TortoiseSvnLockMsgMinSize: if (!cache.LockMessageMinSize.HasValue && !string.IsNullOrEmpty(pv.StringValue) && int.TryParse(pv.StringValue, out intValue)) { cache.LockMessageMinSize = intValue; } break; case SvnPropertyNames.TortoiseSvnLogWidthLine: if (!cache.LogWidth.HasValue && !string.IsNullOrEmpty(pv.StringValue) && int.TryParse(pv.StringValue, out intValue)) { cache.LogWidth = intValue; } break; case SvnPropertyNames.TortoiseSvnLogSummary: if (cache.LogSummary == null) cache.LogSummary = pv.StringValue; break; case AnkhSccPropertyNames.IssueRepositoryConnector: cache.IssueRepositoryConnectorName = pv.StringValue; break; case AnkhSccPropertyNames.IssueRepositoryUri: cache.IssueRepositoryUri = pv.StringValue; break; case AnkhSccPropertyNames.IssueRepositoryId: cache.IssueRepositoryId = pv.StringValue; break; case AnkhSccPropertyNames.IssueRepositoryPropertyNames: cache.IssueRepositoryPropertyNames = pv.StringValue; break; case AnkhSccPropertyNames.IssueRepositoryPropertyValues: cache.IssueRepositoryPropertyValues = pv.StringValue; break; } }
private void LoadSolutionProperties(SettingsCache cache, SvnItem item) { // Subversion -1.5 loads all properties in memory at once; loading them // all is always faster than loading a few // We must change this algorithm if Subversions implementation changes SvnPropertyCollection pc = GetAllProperties(item.FullPath); if (pc != null) foreach (SvnPropertyValue pv in pc) { switch (pv.Key) { case AnkhSccPropertyNames.ProjectRoot: SetProjectRootViaProperty(cache, pv.StringValue); break; default: LoadPropertyBoth(cache, pv); break; } } }
// GET: api/s //this function will be called when installaiton is finished and we are getting a call from th DLM public string Get() { string sUID, fullUrl, pixelURL, retValue, requestCountryCode; string ip_address, res_countryCode; ip_address = res_countryCode = requestCountryCode = string.Empty; Guid tmpGuid; Int32 intProviderId; retValue = "OK"; fullUrl = Request.RequestUri.AbsoluteUri; //Get uid from request sUID = Pixel.Web.Models.pixHelpers.GetQueryString(Request, "uid"); log.Info("Got request from DLM: " + fullUrl); // if sUID cannot be converted to GUID - no point in moving forward if (Guid.TryParse(sUID, out tmpGuid)) { //get requet with equivilant sUID var db = new PetaPoco.Database("myConnectionString"); tmpRequest = db.SingleOrDefault <pixRequests>("SELECT * FROM requests WHERE reqGuid=@0", tmpGuid.ToString()); if (tmpRequest != null) { //get providerID from request intProviderId = tmpRequest.providerid; intRequestPageId = tmpRequest.pageid; requestCountryCode = tmpRequest.countryCode; //Get full provider record from cache according to provifderID tmpProvider = SettingsCache.GetProvider(intProviderId); if (tmpProvider != null) { log.Info("Found provider: " + tmpProvider.id.ToString() + " ,building response URL"); //getting server to server url and changing return param value if (intProviderId == 1008) { string countryCode = tmpRequest.countryCode.ToUpper(); tmpProvider.pixel_url = getMondoS2SURL(countryCode); } pixelURL = buildS2SURL(tmpProvider, tmpRequest); //set up parameters for responses handel var myResponse = new pixResponses(); myResponse.sentToProvider = false; // check if we need to send response to provider //if (blnSendPixel() && sendResponseByCountry(intRequestPageId, requestCountryCode)) string country_Code = tmpRequest.countryCode; if (blnSendPixel() && Pixel.Web.Models.SettingsCache.GetPaidGEO(country_Code)) { try { //send actual response only in production environment if (Pixel.Web.Models.SettingsCache.SEND_RESPONSE) { //send response to provider WebClient proxy = new WebClient(); log.Info("Sending pixel response to Provider: " + pixelURL); Thread.Sleep(300); var response = proxy.DownloadString(pixelURL); proxy.Dispose(); myResponse.sentToProvider = true; } } catch (Exception e) { log.Fatal("Error in sending response to provider: " + pixelURL, e); retValue = "ERROR 2"; } } // save all good response to database myResponse.full_url = fullUrl; myResponse.response_url = pixelURL; myResponse.resGuid = tmpRequest.reqGuid; myResponse.providerid = tmpRequest.providerid; myResponse.pageid = tmpRequest.pageid; myResponse.countryCode = tmpRequest.countryCode; try { db.Insert(myResponse); db.CloseSharedConnection(); } catch (Exception e) { db.CloseSharedConnection(); log.Fatal("Could not insert Response to database with url: " + fullUrl, e); retValue = "ERROR 1"; } //**************************************************************************************************************************** } else { log.Fatal("Counld not find provider id in: " + fullUrl + ", notification will not be sent"); retValue = "ERROR 3"; } } else //a is null { log.Fatal("could not find a request in the database with the following GUID: " + sUID); retValue = "ERROR 4"; } } else { ip_address = Pixel.Web.Models.pixHelpers.GetIPAddress(); res_countryCode = Pixel.Web.Models.pixHelpers.GetLocationFromIPDB(ip_address); log.Fatal("The uid we got from DLM is empty or cannot be converted to guid : " + fullUrl + " IP: " + ip_address + ", countryCode: " + res_countryCode); insertErrorResponse(fullUrl); retValue = "ERROR 5"; } return(retValue); }
public SettingsContainer(L aLowerPriority, SettingsCache aSettingsCache) { LowerPriority = aLowerPriority; SettingsCache = aSettingsCache; }
public IReadOnlyList <string> GetValues(string setting) { return(SettingsCache.GetValues(setting)); }
//this prosudere will determine if we need to send pixel accoording to provider data from database private Boolean blnSendPixel() { //building application counter name for each provider to count number of responses string appKey = string.Empty; int responseCounterValue, SendResponseEvery; string _countryCode = tmpRequest.countryCode; int _pageid = tmpRequest.pageid; int _providerid = tmpRequest.providerid; bool retVal = false; //how often should we send responses to this provider SendResponseEvery = tmpProvider.sendResponseEvery; // try to get a specific X for this page, if it does not exist it will retur -1 and we will get back to the default int i = SettingsCache.getGeoX(_pageid, _countryCode, _providerid); if (i > -1) { // appKey = "provider_" + tmpRequest.providerid.ToString() + "_page_" + _pageid.ToString() + "_" + _countryCode + "_RC"; SendResponseEvery = i; } // else{ // appKey = "provider_" + tmpRequest.providerid.ToString() + "_RC"; // } appKey = "provider_" + tmpRequest.providerid.ToString() + "_page_" + _pageid.ToString() + "_" + _countryCode + "_RC"; responseCounterValue = 0; if (SendResponseEvery != 1) // if we need to send each time there is not use to check. { try { //Get the current X from database and var oVar_responseCounterValue = new SqlParameter("@retval", SqlDbType.Int); oVar_responseCounterValue.Direction = ParameterDirection.Output; oVar_responseCounterValue.Size = 3; var s = PetaPoco.Sql.Builder.Append(";EXEC SP_InstallX @0, @1 OUTPUT", appKey, oVar_responseCounterValue); new PetaPoco.Database("myConnectionString").Execute(s); responseCounterValue = Convert.ToInt32(oVar_responseCounterValue.Value); log.Info("appKey: " + appKey + " = " + responseCounterValue.ToString()); } catch (Exception e) { log.Fatal("Erorr executing SP_InstallX for: " + appKey, e); return(true); } retVal = !((responseCounterValue % SendResponseEvery) != 0); //log.Error("SENDING PIXEL STATUS: " + appKey + ", responseCounterValuec=" + responseCounterValue.ToString() + ", SendResponseEvery = " + SendResponseEvery.ToString() + ", STATUS= " + retVal.ToString()) ; log.Info("Need to send pixel to provider: " + appKey + " = " + retVal.ToString()); return(retVal); } return(true); }
/// <summary> /// Removes the specific configuration section from the .git/config file. /// </summary> /// <param name="configSectionName">The name of the configuration section.</param> /// <param name="performSave">If <see langword="true"/> the configuration changes will be saved immediately.</param> public void RemoveConfigSection(string configSectionName, bool performSave = false) { SettingsCache.RemoveConfigSection(configSectionName, performSave); }
/// <summary> /// Adds the specific configuration section to the .git/config file. /// </summary> /// <param name="configSection">The configuration section.</param> public void AddConfigSection(IConfigSection configSection) { SettingsCache.AddConfigSection(configSection); }
public IReadOnlyList <IConfigSection> GetConfigSections() { return(SettingsCache.GetConfigSections()); }
private IEnumerable<IssueMarker> PerformAllInOne(SettingsCache sc, string logmessage) { foreach (Match m in sc.AllInOneRe.Matches(logmessage)) { if (!m.Success) continue; bool first = true; foreach (Group g in m.Groups) { if (first) first = false; else foreach (Capture c in g.Captures) yield return new IssueMarker(c.Index, c.Length, c.Value); } } }
public IList <ConfigSection> GetConfigSections() { return(SettingsCache.GetConfigSections()); }
private IEnumerable<IssueMarker> PerformSplit(SettingsCache cache, string logmessage) { foreach (Match m in cache.LogPrepareRe.Matches(logmessage)) { if (!m.Success) continue; foreach (Capture c in m.Captures) { string text = logmessage.Substring(c.Index, c.Length); foreach (Match sm in cache.LogSplitRe.Matches(c.Value)) { if (!sm.Success) continue; foreach (Capture sc in sm.Captures) { yield return new IssueMarker(c.Index + sc.Index, sc.Length, sc.Value); } } } } }
public void RemoveConfigSection(string configSectionName) { SettingsCache.RemoveConfigSection(configSectionName); }