Exemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string             openIdType     = "Ecdev.plugins.openid.alipay.alipayservice";
            OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);

            if (openIdSettings == null)
            {
                return;
            }
            string value = base.Request.QueryString["alipaytoken"];

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings));
            System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
            sortedDictionary.Add("service", "user.logistics.address.query");
            sortedDictionary.Add("partner", xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText);
            sortedDictionary.Add("_input_charset", "utf-8");
            sortedDictionary.Add("return_url", Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("LogisticsAddress_url")));
            sortedDictionary.Add("token", value);
            System.Collections.Generic.Dictionary <string, string> dictionary = OpenIdFunction.FilterPara(sortedDictionary);
            string value2 = OpenIdFunction.BuildMysign(dictionary, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8");

            dictionary.Add("sign", value2);
            dictionary.Add("sign_type", "MD5");
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            foreach (System.Collections.Generic.KeyValuePair <string, string> current in dictionary)
            {
                stringBuilder.Append(OpenIdFunction.CreateField(current.Key, current.Value));
            }
            sortedDictionary.Clear();
            dictionary.Clear();
            OpenIdFunction.Submit(OpenIdFunction.CreateForm(stringBuilder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8"));
        }
Exemplo n.º 2
0
 public System.Collections.Generic.SortedDictionary <string, string> GetDistriubots(DistributorQuery query)
 {
     System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
     if (query.GradeId.HasValue)
     {
         sortedDictionary.Add("GradeId", query.GradeId.Value.ToString());
     }
     if (query.LineId.HasValue)
     {
         sortedDictionary.Add("LineId", query.LineId.Value.ToString());
     }
     sortedDictionary.Add("SortBy", query.SortBy);
     if (query.SortOrder == SortAction.Desc)
     {
         sortedDictionary.Add("SortOrder", "0");
     }
     else
     {
         sortedDictionary.Add("SortOrder", "1");
     }
     sortedDictionary.Add("RealName", query.RealName);
     sortedDictionary.Add("Username", query.Username);
     sortedDictionary.Add("PageIndex", query.PageIndex.ToString());
     sortedDictionary.Add("PageSize", query.PageSize.ToString());
     return(sortedDictionary);
 }
Exemplo n.º 3
0
        private void IsVisibleCallRecursive(ItemCollection e_ItemCollection, System.Collections.Generic.SortedDictionary <int, object> e_VisibleArrayList)
        {
            // Print each node recursively.
            var l_pItems = e_ItemCollection;

            foreach (TreeViewItem l_TreeViewItem in l_pItems)
            {
                if (l_TreeViewItem.IsVisible)
                {
                    //https://social.msdn.microsoft.com/Forums/vstudio/en-US/281a8cdd-69a9-4a4a-9fc3-c039119af8ed/absolute-screen-coordinates-of-wpf-user-control?forum=wpf
                    //Point locationFromWindow = Button1.TranslatePoint(new Point(0, 0), this);
                    //Point locationFromScreen = Button1.PointToScreen(locationFromWindow);
                    Point l_Pos = l_TreeViewItem.TranslatePoint(new Point(0, 0), this.m_TreeView);
                    if (l_Pos.Y >= 0 && l_Pos.Y <= this.m_TreeView.RenderSize.Height)
                    {
                        if (e_VisibleArrayList.Keys.Contains((int)l_Pos.Y))
                        {
                            e_VisibleArrayList.Clear();
                            object l_NullSender            = null;
                            ScrollChangedEventArgs l_NullE = null;
                            TreeView_ScrollChanged(l_NullSender, l_NullE);
                            return;
                        }
                        e_VisibleArrayList.Add((int)l_Pos.Y, l_TreeViewItem);
                    }
                }
                IsVisibleCallRecursive(l_TreeViewItem.Items, e_VisibleArrayList);
            }
        }
Exemplo n.º 4
0
 protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
 {
     if (_IsCached)
     {
         base.RenderContents(writer);
     }
     else
     {
         if (SupportsCaching() && IsViewMode() && !Common.Globals.IsAdminControl())
         {
             string       _cachedOutput = Null.NullString;
             StringWriter tempWriter    = new StringWriter();
             _Control.RenderControl(new HtmlTextWriter(tempWriter));
             _cachedOutput = tempWriter.ToString();
             if (!string.IsNullOrEmpty(_cachedOutput) && (!HttpContext.Current.Request.Browser.Crawler))
             {
                 byte[] moduleContent        = System.Text.Encoding.UTF8.GetBytes(_cachedOutput);
                 ModuleCachingProvider cache = ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod());
                 System.Collections.Generic.SortedDictionary <string, string> varyBy = new System.Collections.Generic.SortedDictionary <string, string>();
                 varyBy.Add("locale", System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
                 string cacheKey = cache.GenerateCacheKey(_ModuleConfiguration.TabModuleID, varyBy);
                 cache.SetModule(_ModuleConfiguration.TabModuleID, cacheKey, new TimeSpan(0, 0, _ModuleConfiguration.CacheTime), moduleContent);
             }
             writer.Write(_cachedOutput);
         }
         else
         {
             base.RenderContents(writer);
         }
     }
 }
Exemplo n.º 5
0
        private bool TryLoadCached()
        {
            bool   bSuccess       = false;
            string _cachedContent = string.Empty;

            try
            {
                ModuleCachingProvider cache = ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod());
                System.Collections.Generic.SortedDictionary <string, string> varyBy = new System.Collections.Generic.SortedDictionary <string, string>();
                varyBy.Add("locale", System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
                string cacheKey    = cache.GenerateCacheKey(_ModuleConfiguration.TabModuleID, varyBy);
                byte[] cachedBytes = ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod()).GetModule(_ModuleConfiguration.TabModuleID, cacheKey);
                if (cachedBytes != null && cachedBytes.Length > 0)
                {
                    _cachedContent = System.Text.Encoding.UTF8.GetString(cachedBytes);
                    bSuccess       = true;
                }
            }
            catch (Exception ex)
            {
                _cachedContent = string.Empty;
                bSuccess       = false;
                ex.ToString();
            }
            if (bSuccess)
            {
                _Control = new CachedModuleControl(_cachedContent);
                this.Controls.Add(_Control);
            }
            return(bSuccess);
        }
Exemplo n.º 6
0
            /// <summary>
            /// Call this function if text is added to the temp file (the one that is compiled).
            /// Automatically clears itself when called with LineNumber==0.
            /// Note: PositionOfAddedLine==1 means at the very top was something inserted.
            /// </summary>
            /// <param name="LineNumber">indicates where lines are added</param>
            /// <param name="LineCount">indicates how many line are added at that location</param>
            public void AddOffset(int PositionOfAddedLine, int NumberOfAddedLines)
            {
                //if there are offsets below the just inserted one, then all lower offsets have to be shifted down accordingly.
                System.Collections.Generic.SortedDictionary <int, int> TempDict = new SortedDictionary <int, int>();
                List <int> DeleteKeyList = new List <int>();

                foreach (System.Collections.Generic.KeyValuePair <int, int> entry in LineOffsetDict)
                {
                    if (PositionOfAddedLine <= entry.Key)
                    {
                        TempDict[entry.Key + NumberOfAddedLines] = LineOffsetDict[entry.Key] + NumberOfAddedLines;
                        DeleteKeyList.Add(entry.Key);
                    }
                    else if (PositionOfAddedLine > entry.Key)
                    {
                        break;
                    }
                }

                foreach (int key in DeleteKeyList)
                {
                    LineOffsetDict.Remove(key);
                }
                foreach (System.Collections.Generic.KeyValuePair <int, int> entry in TempDict)
                {
                    LineOffsetDict[entry.Key] = TempDict[entry.Key];
                }

                LineOffsetDict.Add(PositionOfAddedLine, NumberOfAddedLines);
            }
Exemplo n.º 7
0
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            //InvokeOnMainThread(() =>
            {
                bool found = false;

                int cnt;

                lock (TagInfoList)
                {
                    string epcstr = info.epc.ToString();

                    try
                    {
                        TagInfoListSpeedup.Add(epcstr, TagInfoList.Count);

                        TagInfoViewModel item = new TagInfoViewModel();

                        item.timeOfRead = DateTime.Now;
                        item.EPC        = info.epc.ToString();
                        item.Bank1Data  = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                        item.Bank2Data  = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                        item.RSSI       = info.rssi;
                        //item.Phase = info.phase;
                        //item.Channel = (byte)info.freqChannel;
                        item.PC = info.pc.ToUshorts()[0];

                        //TagInfoList.Add(item);
                        TagInfoList.Insert(0, item);

                        _newtagCount4BeepSound++;
                        _newtagCount4Vibration++;

                        Trace.Message("EPC Data = {0}", item.EPC);

                        //_newTag = true;
                    }
                    catch (Exception ex)
                    {
                        int index;

                        if (TagInfoListSpeedup.TryGetValue(epcstr, out index))
                        {
                            index = TagInfoList.Count - index;
                            index--;

                            TagInfoList[index].Bank1Data = CSLibrary.Tools.Hex.ToString(info.Bank1Data);
                            TagInfoList[index].Bank2Data = CSLibrary.Tools.Hex.ToString(info.Bank2Data);
                            TagInfoList[index].RSSI      = info.rssi;
                        }
                        else
                        {
                            // error found epc
                        }
                    }
                }
            }//);
        }
Exemplo n.º 8
0
        public override void Put(object Key, object Value)
        {
            if (Get(Key) == null)
            {
                TimeStamp++;
                Data.Add(Key, new LRUCacheValueEntry(TimeStamp, Value));
                TimeStamps.Add(TimeStamp, Key);

                if (Data.Count > Capacity)
                {
                    SortedDictionary <long, object> .Enumerator enumTimeStamps = TimeStamps.GetEnumerator();
                    enumTimeStamps.MoveNext();
                    long key = enumTimeStamps.Current.Key;
                    Data.Remove(TimeStamps[key]);
                    TimeStamps.Remove(key);
                }
            }
        }
Exemplo n.º 9
0
    void Scoreboard_AddWarlock(int _iSlotID, string _Name, int _iKills, int _iDeaths, int _iScore)
    {
        if (mPlayers.ContainsKey(_iSlotID))
        {
            Debug.LogError("Attempted to add player " + _iSlotID + ", but they already exist!");
            return;
        }

        // Add new player.
        mPlayers.Add(_iSlotID, new ScoreboardVarStruct(_Name, _iKills, _iDeaths, _iScore));
    }
Exemplo n.º 10
0
 internal static void Add(Type type, FastCreateInstanceHandler handler)
 {
     if (type == null)
     {
         return;
     }
     lock (syncLocker)
     {
         Cache.Add(type.GUID, new DTOType(type, handler));
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Ajoute un contrat à la collection
        /// </summary>
        /// <param name="unContrat"></param>

        public void AjouterContrat(MContrat unContrat)
        {
            if (Contrats.ContainsKey(unContrat.NumeroContrat))
            {
                throw new Exception("Le numero de contrat existe deja ou il est de valeur 0");
            }
            else
            {
                Contrats.Add(unContrat.NumeroContrat, unContrat);
            }
        }
Exemplo n.º 12
0
 private System.Collections.Generic.SortedDictionary <string, string> GetRequestPost()
 {
     System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
     System.Collections.Specialized.NameValueCollection           form             = base.Request.Form;
     string[] allKeys = form.AllKeys;
     for (int i = 0; i < allKeys.Length; i++)
     {
         sortedDictionary.Add(allKeys[i], base.Request.Form[allKeys[i]]);
     }
     return(sortedDictionary);
 }
Exemplo n.º 13
0
 public System.Collections.Generic.SortedDictionary <string, string> GetRequestGet()
 {
     System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
     System.Collections.Specialized.NameValueCollection           queryString      = base.Request.QueryString;
     string[] allKeys = queryString.AllKeys;
     for (int i = 0; i < allKeys.Length; i++)
     {
         sortedDictionary.Add(allKeys[i], base.Request.QueryString[allKeys[i]]);
     }
     return(sortedDictionary);
 }
 private static void CreateVariablesTypes()
 {
     _variableTypes.Add("DOCVARIABLE", new ucDOCVARIABLE());
     _variableTypes.Add("PAGE", new ucPAGENUMBER("PAGE"));
     _variableTypes.Add("NUMPAGES", new ucPAGENUMBER("NUMPAGES"));
     _variableTypes.Add("CREATEDATE", new ucCREATEDATE());
     _variableTypes.Add("DATE", new ucCREATEDATE());
     _variableTypes.Add("TIME", new ucCREATEDATE());
     _variableTypes.Add("IF", new ucIFFIELD());
 }
Exemplo n.º 15
0
        public System.Collections.Generic.SortedDictionary <string, ListtemplateColumn> ListtemplateColumnsSort(string ListName)
        {
            System.Collections.Generic.SortedDictionary <string, ListtemplateColumn> scol = new System.Collections.Generic.SortedDictionary <string, ListtemplateColumn>();
            listtemplate list = this.listtemplates.getListtemplate(ListName);

            if (list != null)
            {
                foreach (ListtemplateColumn col in list.ListtemplateColumns)
                {
                    scol.Add(col.Seqnr, col);
                }
            }
            return(scol);
        }
Exemplo n.º 16
0
 public BaseDataObjectTypeIdAttribute(string id, Type deserializerType, string deserializerProcedureName)
 {
     if (deserializerType == null)
     {
         throw new ArgumentNullException("deserializerType");
     }
     if (deserializerProcedureName == null)
     {
         throw new ArgumentNullException("deserializerProcedureName");
     }
     this.id = Guid.Parse(id);
     this.deserializerType          = deserializerType;
     this.deserializerProcedureName = deserializerProcedureName;
     attribs.Add(this.id, this);
     ResolveMethod();
 }
Exemplo n.º 17
0
 public static System.Collections.Generic.SortedDictionary <string, string> GetSortedParams(System.Web.HttpContext context)
 {
     System.Collections.Generic.SortedDictionary <string, string> sortedDictionary    = new System.Collections.Generic.SortedDictionary <string, string>();
     System.Collections.Specialized.NameValueCollection           nameValueCollection = new System.Collections.Specialized.NameValueCollection
     {
         context.Request.Form,
         context.Request.QueryString
     };
     string[] allKeys = nameValueCollection.AllKeys;
     for (int i = 0; i < allKeys.Length; i++)
     {
         sortedDictionary.Add(allKeys[i], nameValueCollection[allKeys[i]]);
     }
     sortedDictionary.Remove("HIGW");
     return(sortedDictionary);
 }
Exemplo n.º 18
0
        //private static HttpSessionState session { get { return HttpContext.Current.Session; } }
        public static void CheckXSRF(Page page, HiddenField antiforgery)
        {
            string antiforgeryToken = string.Empty;

            antiforgeryToken = GenerateCustomizedCSRFToken();
            System.Collections.Generic.SortedDictionary <string, string> l_CSRFTokenCollection = new System.Collections.Generic.SortedDictionary <string, string>();

            if (!page.IsPostBack)
            {
                if (l_CSRFTokenCollection.ContainsKey(page.AppRelativeVirtualPath.ToUpper()))
                {
                    l_CSRFTokenCollection.Remove(page.AppRelativeVirtualPath.ToUpper());
                }
                l_CSRFTokenCollection.Add(page.AppRelativeVirtualPath.ToUpper(), antiforgeryToken);

                page.Session.Add("CSRFTokens", l_CSRFTokenCollection);

                antiforgery.Value = antiforgeryToken;

                antiforgeryToken = string.Empty;
            }
            else
            {
                if (page.Session["CSRFTokens"] == null)
                {
                    throw new HttpException("Validation of Anti-XSRF token failed.");
                }

                l_CSRFTokenCollection = (System.Collections.Generic.SortedDictionary <string, string>)page.Session["CSRFTokens"];
                if (!l_CSRFTokenCollection.ContainsKey(page.AppRelativeVirtualPath.ToUpper()))
                {
                    throw new HttpException("Validation of Anti-XSRF token failed.");
                }
                if ((antiforgery.Value != l_CSRFTokenCollection[page.AppRelativeVirtualPath.ToUpper()]))
                {
                    throw new HttpException("Validation of Anti-XSRF token failed.");
                }

                //l_CSRFTokenCollection.Remove(page.AppRelativeVirtualPath);

                //l_CSRFTokenCollection.Add(page.AppRelativeVirtualPath, antiforgeryToken);

                //page.Session.Add("CSRFTokens", l_CSRFTokenCollection);

                //antiforgery.Value = antiforgeryToken;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Reads a fingerprint file wit NIC MAC addresses. The file shall be formatted according to Ettercap
        /// </summary>
        /// <param name="macFingerprintFilename">for example "etter.finger.mac"</param>
        private MacCollection(string macFingerprintFilename, MacFingerprintFileFormat format)
        {
            //System.IO.File.OpenRead(macFingerprintFilename)
            //Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
            //Environment.CurrentDirectory;

            System.IO.FileStream fileStream = new FileStream(macFingerprintFilename, FileMode.Open, FileAccess.Read);
            StreamReader         reader     = new StreamReader(fileStream);

            macPrefixDictionary = new SortedDictionary <string, string>();
            macFullDictionary   = new SortedDictionary <string, string>();
            macFullDictionary.Add("FF:FF:FF:FF:FF:FF", "Broadcast");

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                //see if it is an empty or commented line
                if (line.Length > 0 && line[0] != '#')
                {
                    string macKey = null;
                    string vendor = null;
                    if (format == MacFingerprintFileFormat.Ettercap && line.Length > 10)
                    {
                        macKey = line.Substring(0, 8);//for example 00:00:01
                        vendor = line.Substring(10);
                    }
                    else if (format == MacFingerprintFileFormat.Nmap && line.Length > 7)
                    {
                        macKey = line.Substring(0, 2) + ":" + line.Substring(2, 2) + ":" + line.Substring(4, 2);
                        vendor = line.Substring(7);
                    }
                    else if (format == MacFingerprintFileFormat.IEEE_OUI && line.Length > 15 && line.Contains("(hex)") && line.TrimStart(WHITESPACE)[2] == '-')
                    {
                        line   = line.TrimStart(WHITESPACE);
                        macKey = line.Substring(0, 8).Replace('-', ':');
                        vendor = line.Substring(line.LastIndexOf('\t') + 1);
                    }
                    if (macKey != null && vendor != null && !macPrefixDictionary.ContainsKey(macKey))
                    {
                        macPrefixDictionary.Add(macKey, vendor);
                    }
                    //hashTable.Add(mac, vendor);
                }
            }
        }
Exemplo n.º 20
0
        public void TeachPhrase(string rawPhrase)
        {
            if ((null != _mExcluded) && (_mExcluded.IsExcluded(rawPhrase)))
            {
                return;
            }

            PhraseCount pc;
            string      Phrase = DePhrase(rawPhrase);

            if (!MPhrases.TryGetValue(Phrase, out pc))
            {
                pc = new PhraseCount(rawPhrase);
                MPhrases.Add(Phrase, pc);
            }
            pc.Count++;
            _totalWords++;
        }
Exemplo n.º 21
0
        /// <summary>
        /// This Function delivers the first (means: oldest) VALID file in the list (if checkFileValidity is true).
        /// This flag can be changed to false (or removed) if it is assured that only valid files are deployed in the import folder.
        /// </summary>
        /// <param name="files">List of strings with the filenames</param>
        /// <param name="checkFileValidity">bool. if set to true (default) this will perform a simple validity check.</param>
        /// <returns>string with the oldest file.</returns>
        public static string GetOldestFile(List <string> files)
        {
            SortedDictionary <DateTime?, string> sortedFiles = new System.Collections.Generic.SortedDictionary <DateTime?, string>();

            foreach (string file in files)
            {
                DateTime?date = ParseSenderDate(file);
                if (date == null)
                {
                    continue;
                }
                if (Parser.AxisReader2.CheckFileIsValid(file))
                {
                    sortedFiles.Add(date, file);
                }
            }

            return(sortedFiles.Count > 0 ? sortedFiles.First().Value : null);
        }
Exemplo n.º 22
0
        private void createTypeElement(ref System.Xml.XmlDocument pdoc, string pid, string pname, string pcore, System.Collections.Generic.Dictionary <int, ContenttypeColumn> pfieldstable)
        {
            System.Xml.XmlElement contenttype = pdoc.CreateElement("", "ContentType", ns);
            contenttype.SetAttribute("ID", pid);
            contenttype.SetAttribute("Name", pname);
            contenttype.SetAttribute("Group", "$Resources:" + pcore + ",TypesGroupName;");
            contenttype.SetAttribute("Description", "$Resources:" + pcore + "," + pname + ";");
            contenttype.SetAttribute("Version", "0");

            System.Xml.XmlElement fieldrefs = pdoc.CreateElement("", "FieldRefs", ns);
            contenttype.AppendChild(fieldrefs);

            System.Collections.Generic.SortedDictionary <string, ContenttypeColumn> scol = new System.Collections.Generic.SortedDictionary <string, ContenttypeColumn>();
            foreach (ContenttypeColumn col in pfieldstable.Values)
            {
                scol.Add(col.Seqnr, col);
            }

            foreach (ContenttypeColumn col in scol.Values)
            {
                if (!col.SysCol)
                {
                    System.Xml.XmlElement fieldref = pdoc.CreateElement("", "FieldRef", ns);
                    fieldref.SetAttribute("ID", col.colGUID);
                    fieldref.SetAttribute("Name", col.SysName);
                    fieldrefs.AppendChild(fieldref);
                }
            }

            System.Xml.XmlNode elements = pdoc.SelectSingleNode("//mha:Elements", nsMgr);
            string             filter   = "//mha:ContentType[@ID=\"" + pid + "\"]";

            System.Xml.XmlNode old_contenttype = elements.SelectSingleNode(filter, nsMgr);

            if (old_contenttype == null)
            {
                elements.AppendChild(contenttype);
            }
            else
            {
                elements.ReplaceChild(contenttype, old_contenttype);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Trains this Category from a word or phrase<\summary>
        /// <seealso cref="DePhrase(string)">
        /// See DePhrase </seealso>
        public void TeachPhrase(string rawPhrase, bool useWordStemmer = false)
        {
            rawPhrase = rawPhrase.ToLower();    // Eliminate case-sensitivity

            if ((null != m_Excluded) && (m_Excluded.IsStopword(rawPhrase)))
            {
                return;
            }

            BayesPhraseCount pc;
            string           Phrase = GetWordStem(DePhrase(rawPhrase), useWordStemmer);

            rawPhrase = GetWordStem(rawPhrase, useWordStemmer);   // Reduce the words to their "stems" so that something like "birds" matches "bird"
            if (!m_Phrases.TryGetValue(Phrase, out pc))
            {
                pc = new BayesPhraseCount(rawPhrase);
                m_Phrases.Add(Phrase, pc);
            }
            pc.Count++;
            m_TotalWords++;
        }
Exemplo n.º 24
0
        public static bool GetAnnotationDefaults(string filepath, ref System.Collections.Generic.SortedDictionary <string, string> annotationDefaults)
        {
            System.Xml.XmlDocument AnnotationsDoc = new XmlDocument();
            AnnotationsDoc.Load(filepath);


            // get list of DAM element sections, iterate through their child nodes, adding each to a new node that will be added to TDConfigDoc
            XmlNodeList annotationSets = AnnotationsDoc.DocumentElement.SelectNodes("/ArrayOfAnnotationSet/AnnotationSet");


            foreach (XmlElement confignode in annotationSets)
            {
                var Names    = confignode.GetElementsByTagName("Name");
                var name     = Names.Item(0);
                var Defaults = confignode.GetElementsByTagName("IsDefault");
                var Default  = Defaults.Item(0);

                annotationDefaults.Add(name.InnerText, Default.InnerText);
            }

            return(false);
        }
Exemplo n.º 25
0
            /// <summary>
            /// Call this function if text is added to the temp file (the one that is compiled).
            /// Automatically clears itself when called with LineNumber==0.
            /// Note: PositionOfAddedLine==1 means at the very top was something inserted.
            /// </summary>
            /// <param name="LineNumber">indicates where lines are added</param>
            /// <param name="LineCount">indicates how many line are added at that location</param>
            public void AddOffset(int PositionOfAddedLine, int NumberOfAddedLines)
            {
                LineOffsetDict.Add(PositionOfAddedLine, NumberOfAddedLines);

                //if there are offset are the just inserted one, that all have to be adapted accordingly.
                System.Collections.Generic.SortedDictionary <int, int> TempDict = new SortedDictionary <int, int>();
                foreach (System.Collections.Generic.KeyValuePair <int, int> entry in LineOffsetDict)
                {
                    if (PositionOfAddedLine < entry.Key)
                    {
                        TempDict[entry.Key] = LineOffsetDict[entry.Key] + NumberOfAddedLines;
                    }
                    else if (PositionOfAddedLine > entry.Key)
                    {
                        break;
                    }
                }
                foreach (System.Collections.Generic.KeyValuePair <int, int> entry in TempDict)
                {
                    LineOffsetDict[entry.Key] = TempDict[entry.Key];
                }
            }
Exemplo n.º 26
0
        public static int LargestUniqueNumber(int[] A)
        {
            try
            {
                int       ret   = -1;
                ArrayList dummy = new ArrayList();

                var m = new System.Collections.Generic.SortedDictionary <int, int>(); //taking a sorted dict
                Array.Sort(A);
                int   n   = A.Length;
                int[] arr = new int[A.Length];
                for (int i = 0; i < n; i++)
                {
                    if (!m.ContainsKey(A[i]))
                    {
                        m.Add(A[i], i); //adding char of string in key and index to value in dict
                    }
                    else
                    {
                        dummy.Add(A[i]);//if any repeated element hits it will be added to dummy lit
                    }
                }
                foreach (int d in dummy) // for each repeated element in dummy loop remove the corresponding element from dict
                {
                    if (m.ContainsKey(d))
                    {
                        m.Remove(d);
                    }
                }
                ret = m.Keys.Last();//returns the max i.e last key as it is sorted dict
                return(ret);
            }
            catch
            {
                return(-1);
            }
        }
Exemplo n.º 27
0
 protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
 {
     if (_IsCached)
     {
         base.RenderContents(writer);
     }
     else
     {
         if (SupportsCaching() && IsViewMode() && !Common.Globals.IsAdminControl())
         {
             string _cachedOutput = Null.NullString;
             StringWriter tempWriter = new StringWriter();
             _Control.RenderControl(new HtmlTextWriter(tempWriter));
             _cachedOutput = tempWriter.ToString();
             if (!string.IsNullOrEmpty(_cachedOutput) && (!HttpContext.Current.Request.Browser.Crawler))
             {
                 byte[] moduleContent = System.Text.Encoding.UTF8.GetBytes(_cachedOutput);
                 ModuleCachingProvider cache = ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod());
                 System.Collections.Generic.SortedDictionary<string, string> varyBy = new System.Collections.Generic.SortedDictionary<string, string>();
                 varyBy.Add("locale", System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
                 string cacheKey = cache.GenerateCacheKey(_ModuleConfiguration.TabModuleID, varyBy);
                 cache.SetModule(_ModuleConfiguration.TabModuleID, cacheKey, new TimeSpan(0, 0, _ModuleConfiguration.CacheTime), moduleContent);
             }
             writer.Write(_cachedOutput);
         }
         else
         {
             base.RenderContents(writer);
         }
     }
 }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Dictionary <string, Contest> contestAndPass = new Dictionary <string, Contest>();
            string command = Console.ReadLine();

            while (command != "end of contests")
            {
                string name     = command.Split(":")[0];
                string password = command.Split(":")[1];
                if (contestAndPass.ContainsKey(name) == false)
                {
                    Contest contest = new Contest(name, password);
                    contestAndPass.Add(name, contest);
                }

                command = Console.ReadLine();
            }

            SortedDictionary <string, User> usersAndContests = new System.Collections.Generic.SortedDictionary <string, User>();
            string commandTwo = Console.ReadLine();

            while (commandTwo != "end of submissions")
            {
                string nameOfContest = commandTwo.Split("=>")[0];
                string password      = commandTwo.Split("=>")[1];
                if (contestAndPass.ContainsKey(nameOfContest) && contestAndPass[nameOfContest].Password == password)
                {
                    string username = commandTwo.Split("=>")[2];
                    int    points   = int.Parse(commandTwo.Split("=>")[3]);
                    if (usersAndContests.ContainsKey(username))
                    {
                        if (usersAndContests[username].Contests.ContainsKey(nameOfContest))
                        {
                            if (points > usersAndContests[username].Contests[nameOfContest])
                            {
                                usersAndContests[username].Contests[nameOfContest] = points;
                            }
                        }
                        else
                        {
                            usersAndContests[username].Contests.Add(nameOfContest, points);
                        }
                    }
                    else
                    {
                        User user = new User(username, points, nameOfContest);
                        usersAndContests.Add(username, user);
                    }
                }

                commandTwo = Console.ReadLine();
            }

            string bestUser = User.BestUser(usersAndContests);

            Console.WriteLine($"Best candidate is {bestUser} with total {usersAndContests[bestUser].Contests.Values.Sum()} points.");
            Console.WriteLine("Ranking:");

            foreach (var user in usersAndContests)
            {
                Console.WriteLine(user.Key);
                foreach (var item in user.Value.Contests.OrderByDescending(p => p.Value))
                {
                    Console.WriteLine($"#  {item.Key} -> {item.Value}");
                }
            }
        }
Exemplo n.º 29
0
        public byte[] CommitTransaction(SortedSet<BaseDataObjectVersion> objects)
        {
            Log.WriteLine ("Database.CommitTransaction()");
            int oc = objects.Count;
            objects.RemoveWhere (obj => obj.ChunkID != null);
            Log.WriteLine ("Ommitting {0} objects in commit", oc - objects.Count);
            System.IO.MemoryStream MS = new System.IO.MemoryStream ();
            System.IO.MemoryStream MSRP = new System.IO.MemoryStream ();
            System.IO.BinaryWriter MSBW = new System.IO.BinaryWriter (MS);
            SortedSet<byte[]> dependencies = new SortedSet<byte[]> (BD2.Core.ByteSequenceComparer.Shared);
            ChunkHeaderv1 ch = new ChunkHeaderv1 (DateTime.UtcNow, "");
            MSBW.Write (ch.Version);
            byte[] chbytes = ch.Serialize ();
            MSBW.Write (chbytes.Length);
            MSBW.Write (chbytes);
            MSBW.Write (1);//section count
            Log.WriteLine ("{0} sections", 1);
            int n = 0;
            //foreach (var tup in data) {
            MSBW.Write (1);
            Log.WriteLine ("Section version is {0}", 1);
            System.Collections.Generic.SortedDictionary <BaseDataObjectVersion, LinkedListNode<BaseDataObjectVersion>> ss = new  System.Collections.Generic.SortedDictionary <BaseDataObjectVersion, LinkedListNode<BaseDataObjectVersion>> ();
            System.Collections.Generic.LinkedList <BaseDataObjectVersion> ll = new LinkedList<BaseDataObjectVersion> ();
            foreach (BaseDataObjectVersion bdo in objects) {
                if (!ss.ContainsKey (bdo))
                    ss.Add (bdo, ll.AddLast (bdo));

                foreach (BaseDataObjectVersion dependency in bdo.GetDependenies ()) {
                    byte[] dep = dependency.ChunkID;
                    if (dep == null) {
                        if (ss.ContainsKey (bdo)) {

                        } else {

                            ss.Add (dependency, ll.AddBefore (ss [bdo], dependency));

                        }
                    } else {
                        if (!dependencies.Contains (dependency.ChunkID))
                            dependencies.Add (dependency.ChunkID);
                    }
                }
            }
            foreach (BaseDataObjectVersion bdo in ll) {
                n++;
                System.IO.MemoryStream MST = new System.IO.MemoryStream ();
                MST.Write (bdo.ObjectType.ToByteArray (), 0, 16);
                bdo.Serialize (MST, encryptedStorageManager);
                byte[] bytes = MST.ToArray ();
                Log.WriteLine ("object type+bytes: {0}", bytes.ToHexadecimal ());
                //Log.WriteLine ("Object of type {0} serialized to {1} bytes.", bdo.GetType ().FullName, bytes.Length);
                {
                    System.IO.MemoryStream MSC = new System.IO.MemoryStream ();
                    System.IO.BinaryWriter BWC = new System.IO.BinaryWriter (MSC);
                    BWC.Write (bytes.Length);
                    MSRP.Write (MSC.ToArray (), 0, 4);
                }

                MSRP.Write (bytes, 0, bytes.Length);
            }
            byte[] encoded = MSRP.ToArray ();
            Log.WriteLine ("{0} objects encoded in {1} bytes", objects.Count, encoded.Length);
            MSBW.Write (n);
            MSBW.Write (encoded.Length);
            MSBW.Write (encoded);
            Log.WriteLine ("encoded:{0}", encoded.ToHexadecimal ());
            //}
            if (n == 0) {
                Log.WriteLine ("No objects to save, nothing to do");
                return null;
            }
            System.Security.Cryptography.SHA256 sha = System.Security.Cryptography.SHA256.Create ();
            Log.WriteLine ("{0} dependencies", dependencies.Count);
            byte[][] deps = new byte [dependencies.Count][];
            int depid = 0;
            foreach (byte[] dep in dependencies)
                deps [depid++] = dep;
            Log.WriteLine ("Writing {0} bytes representing {1} objects to backend", MS.Length, n);
            byte[] buf = MS.ToArray ();
            byte[] chunkID = sha.ComputeHash (buf);
            foreach (var ds in dataStorage)
                Log.WriteLine ("We have: {0}", ds.Key.ToHexadecimal ());
            byte[] cus = userStorage.GetCommonStorage ();
            Log.WriteLine ("Common storage id is {0}", cus.ToHexadecimal ());
            if (!dataStorage.ContainsKey (cus)) {
                Log.WriteLine ("and we don't have it.");
                Log.WriteLine ("we only have:");
                foreach (var t in dataStorage)
                    Log.WriteLine ("    ID: {0}", t.Key.ToHexadecimal ());
            }
            dataStorage [cus].Push (chunkID, buf, deps, userStorage.Sign (chunkID));
            foreach (var bdo in objects) {
                bdo.SetChunkID (chunkID);
            }
            Log.WriteLine ("Chunk saved with ID:{0}", chunkID.ToHexadecimal ());
            return chunkID;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Extracts all matching students from project and group them by the scores assigned to the students by the project contact in a dictionary whose key is the score and the value is the list of students who got that score.
        /// </summary>
        /// <param name="project">Detached project object which should have had its all properties eagerly loaded, otherwise an exception will be thrown.</param>
        /// <returns>A dictionary whose key is the score assigned to the list of students in the dictionary's value.</returns>
        public static IDictionary<ScoreDetail, IList<Student>> GetStudentsForProjectGroupedByScore(Project project)
        {
            if (project.Matchings == null || project.Matchings.Count == 0 || project.Matchings.Select(m => m.Student).Count() == 0)
                throw new ArgumentException("There are no matching students for the project. Make sure all properties of your project was eagerly loaded before it was passed as parameter.", "project");

            var unsortedDict = project.Matchings.GroupBy(m => UIParamsAndMessages.ProjectScoreDetails.Where(sd => sd.Score == m.ProjectScore).FirstOrDefault())
                                      .ToDictionary(key => key.Key, value => value.Select(m => m.Student).ToList() as IList<Student>);

            System.Collections.Generic.SortedDictionary<ScoreDetail,IList<Student>> dict = new System.Collections.Generic.SortedDictionary<ScoreDetail,IList<Student>>(unsortedDict);

            foreach (ScoreDetail sd in UIParamsAndMessages.ProjectScoreDetails)
            {
                if (!dict.Keys.Contains(sd))
                    dict.Add(sd, new List<Student>());
            }
            return dict;
        }
Exemplo n.º 31
0
		static LineCapExtension()
		{
			_defaultStyle = new LineCaps.FlatCap();

			// first register the old deprecated Gdi styles
			_deprecatedGdiStyles = new System.Collections.Generic.SortedDictionary<string, LineCapExtension>();
			foreach (LineCap cap in Enum.GetValues(typeof(LineCap)))
			{
				switch (cap)
				{
					case LineCap.AnchorMask:
					case LineCap.Flat:
					case LineCap.NoAnchor:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), _defaultStyle);
						break;

					case LineCap.Square:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.SquareFLineCap(0, 1));
						break;

					case LineCap.Round:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.CircleFLineCap(0, 1));
						break;

					case LineCap.Triangle:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.DiamondFLineCap(0, 1));
						break;

					case LineCap.ArrowAnchor:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.ArrowF10LineCap(0, 2));
						break;

					case LineCap.SquareAnchor:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.SquareFLineCap(0, 1.5));
						break;

					case LineCap.RoundAnchor:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.CircleFLineCap(0, 2));
						break;

					case LineCap.DiamondAnchor:
						_deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.DiamondFLineCap(0, 2));
						break;
				}
			}

			// now the other linecaps
			_registeredStyles = new System.Collections.Generic.SortedDictionary<string, LineCapExtension>();
			var types = Altaxo.Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(LineCapExtension));
			foreach (var t in types)
			{
				var ex = (LineCapExtension)Activator.CreateInstance(t);
				_registeredStyles.Add(ex.Name, ex);
			}

			// now sort them by name
			List<string> nameList = new List<string>(_registeredStyles.Keys);
			nameList.Remove(_defaultStyle.Name);
			nameList.Sort();
			nameList.Insert(0, _defaultStyle.Name);
			_registeredStylesSortedByName = new List<LineCapExtension>(nameList.Select(x => _registeredStyles[x]));
		}
Exemplo n.º 32
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            string text  = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string str   = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            string text2 = "";

            Hidistro.Membership.Context.SiteSettings masterSettings = Hidistro.Membership.Context.SettingsManager.GetMasterSettings(false);
            string text3 = context.Request.QueryString["action"].ToString();
            string sign  = context.Request.Form["sign"];

            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            string skucontentformat = "<Item><lid>{0}</lid><OuterId>{1}</OuterId><SKUContent>{2}</SKUContent><Nums>{3}</Nums><Price>{4}</Price></Item>";
            string strformat        = "<product><Iid>{0}</Iid><OuterId>{1}</OuterId><Title>{2}</Title><PicUrl>{3}</PicUrl><Url>{4}</Url><MarketPrice>{5}</MarketPrice><Price>{6}</Price><Weight>{7}</Weight><Status>{8}</Status><SkuItems list=\"{9}\">{10}</SkuItems></product>";

            System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>();
            string checkCode = masterSettings.CheckCode;
            string value     = context.Request.Form["format"];

            try
            {
                if (!string.IsNullOrEmpty(text3))
                {
                    string hostPath = Hidistro.Membership.Context.HiContext.Current.HostPath;
                    string a;
                    if ((a = text3) != null)
                    {
                        if (!(a == "productview"))
                        {
                            if (a == "productsimpleview")
                            {
                                goto IL_7BC;
                            }
                            if (!(a == "stockview"))
                            {
                                if (!(a == "quantity"))
                                {
                                    if (a == "statue")
                                    {
                                        string value2 = context.Request.Form["state"].Trim();
                                        string text4  = context.Request.Form["productId"].Trim();
                                        if (string.IsNullOrEmpty(value2) || string.IsNullOrEmpty(text4))
                                        {
                                            text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "state or productId");
                                            goto IL_7BC;
                                        }
                                        ProductSaleStatus productSaleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), value2, true);
                                        int num = System.Convert.ToInt32(text4);
                                        if (num <= 0)
                                        {
                                            text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                            goto IL_7BC;
                                        }
                                        sortedDictionary.Add("productid", text4);
                                        sortedDictionary.Add("state", value2);
                                        sortedDictionary.Add("format", value);
                                        if (APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                        {
                                            bool flag = false;
                                            stringBuilder.Append("<item_update_statue_response>");
                                            if (productSaleStatus == ProductSaleStatus.OnSale)
                                            {
                                                if (ProductHelper.UpShelf(num) > 0)
                                                {
                                                    flag = true;
                                                }
                                                else
                                                {
                                                    text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                                }
                                            }
                                            else
                                            {
                                                if (productSaleStatus == ProductSaleStatus.UnSale)
                                                {
                                                    if (ProductHelper.OffShelf(num) > 0)
                                                    {
                                                        flag = true;
                                                    }
                                                    else
                                                    {
                                                        text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                                    }
                                                }
                                            }
                                            if (flag)
                                            {
                                                stringBuilder.Append(string.Concat(new string[]
                                                {
                                                    "<item><num_iid>",
                                                    text4,
                                                    "</num_iid><modified>",
                                                    System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                                                    "</modified></item>"
                                                }));
                                            }
                                            else
                                            {
                                                text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, "update");
                                            }
                                            stringBuilder.Append("</item_update_statue_response>");
                                            goto IL_7BC;
                                        }
                                        text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                        goto IL_7BC;
                                    }
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || string.IsNullOrEmpty(context.Request.Form["quantity"].Trim()))
                                    {
                                        text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                                        goto IL_7BC;
                                    }
                                    string text5 = context.Request.Form["productId"];
                                    string text6 = "";
                                    string text7 = "";
                                    int    type  = 1;
                                    int    stock = System.Convert.ToInt32(context.Request.Form["quantity"].Trim());
                                    if (!string.IsNullOrEmpty(context.Request.Form["sku_id"].Trim()))
                                    {
                                        text6 = context.Request.Form["sku_id"];
                                    }
                                    if (!string.IsNullOrEmpty(context.Request.Form["outer_id"].Trim()))
                                    {
                                        text7 = context.Request.Form["outer_id"];
                                    }
                                    if (!string.IsNullOrEmpty(context.Request.Form["type"]))
                                    {
                                        type = System.Convert.ToInt32(context.Request.Form["type"]);
                                    }
                                    sortedDictionary.Add("productId", text5.ToString());
                                    sortedDictionary.Add("quantity", stock.ToString());
                                    sortedDictionary.Add("sku_id", text6);
                                    sortedDictionary.Add("outer_id", text7);
                                    sortedDictionary.Add("type", type.ToString());
                                    sortedDictionary.Add("format", value);
                                    if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                    {
                                        text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                        goto IL_7BC;
                                    }
                                    ApiErrorCode apiErrorCode = ProductHelper.UpdateProductStock(System.Convert.ToInt32(text5), text6, text7, type, stock);
                                    if (ApiErrorCode.Success == apiErrorCode)
                                    {
                                        stringBuilder.Append("<trade_get_response>");
                                        stringBuilder.Append(this.GetProductDetailsView(System.Convert.ToInt32(text5), hostPath, strformat, skucontentformat).ToString());
                                        stringBuilder.Append("</trade_get_response>");
                                        goto IL_7BC;
                                    }
                                    text2 = MessageInfo.ShowMessageInfo(apiErrorCode, "paramters");
                                    goto IL_7BC;
                                }
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || System.Convert.ToInt32(context.Request.Form["ProductId"].Trim()) <= 0)
                                {
                                    text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "productId");
                                    goto IL_7BC;
                                }
                                int num = System.Convert.ToInt32(context.Request.Form["productId"].Trim());
                                sortedDictionary.Add("productid", num.ToString());
                                sortedDictionary.Add("format", value);
                                if (APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                {
                                    stringBuilder.Append("<trade_get_response>");
                                    stringBuilder.Append(this.GetProductDetailsView(num, hostPath, strformat, skucontentformat).ToString());
                                    stringBuilder.Append("</trade_get_response>");
                                    goto IL_7BC;
                                }
                                text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                goto IL_7BC;
                            }
                        }
                        else
                        {
                            ProductQuery productQuery = new ProductQuery
                            {
                                SaleStatus = ProductSaleStatus.OnSale,
                                PageSize   = 10,
                                PageIndex  = 1
                            };
                            string value2 = context.Request.Form["state"].Trim();
                            string value3 = context.Request.Form["pageindex"].Trim();
                            string value4 = context.Request.Form["pagesize"].Trim();
                            if (string.IsNullOrEmpty(value2) || string.IsNullOrEmpty(value3))
                            {
                                text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "state or pageindex");
                                goto IL_7BC;
                            }
                            sortedDictionary.Add("state", value2);
                            sortedDictionary.Add("pageindex", value3);
                            sortedDictionary.Add("pagesize", value4);
                            sortedDictionary.Add("format", value);
                            if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                            {
                                text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                goto IL_7BC;
                            }
                            if (!string.IsNullOrEmpty(value4) && System.Convert.ToInt32(value4) > 0)
                            {
                                productQuery.PageSize = System.Convert.ToInt32(value4);
                            }
                            if (System.Convert.ToInt32(value3) > 0)
                            {
                                productQuery.PageIndex  = System.Convert.ToInt32(value3);
                                productQuery.SaleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), value2, true);
                                Globals.EntityCoding(productQuery, true);
                                int num2 = 0;
                                stringBuilder.Append("<trade_get_response>");
                                stringBuilder.Append(this.GetProductView(productQuery, hostPath, strformat, skucontentformat, out num2).ToString());
                                stringBuilder.Append("<totalrecord>" + num2 + "</totalrecord>");
                                stringBuilder.Append("</trade_get_response>");
                                goto IL_7BC;
                            }
                            text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "pageindex");
                            goto IL_7BC;
                        }
                    }
                    text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters");
IL_7BC:
                    text += stringBuilder.ToString();
                }
                else
                {
                    text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "modeId");
                }
            }
            catch (System.Exception ex)
            {
                text2 = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, ex.Message);
            }
            if (text2 != "")
            {
                text = str + text2;
            }
            context.Response.ContentType = "text/xml";
            context.Response.Write(text);
        }
Exemplo n.º 33
0
        static LineCapExtension()
        {
            _defaultStyle = new LineCaps.FlatCap();

            // first register the old deprecated Gdi styles
            _deprecatedGdiStyles = new System.Collections.Generic.SortedDictionary <string, LineCapExtension>();
            foreach (LineCap cap in Enum.GetValues(typeof(LineCap)))
            {
                switch (cap)
                {
                case LineCap.AnchorMask:
                case LineCap.Flat:
                case LineCap.NoAnchor:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), _defaultStyle);
                    break;

                case LineCap.Square:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.SquareFLineCap(0, 1));
                    break;

                case LineCap.Round:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.CircleFLineCap(0, 1));
                    break;

                case LineCap.Triangle:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.DiamondFLineCap(0, 1));
                    break;

                case LineCap.ArrowAnchor:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.ArrowF10LineCap(0, 2));
                    break;

                case LineCap.SquareAnchor:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.SquareFLineCap(0, 1.5));
                    break;

                case LineCap.RoundAnchor:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.CircleFLineCap(0, 2));
                    break;

                case LineCap.DiamondAnchor:
                    _deprecatedGdiStyles.Add(Enum.GetName(typeof(LineCap), cap), new LineCaps.DiamondFLineCap(0, 2));
                    break;
                }
            }

            // now the other linecaps
            _registeredStyles = new System.Collections.Generic.SortedDictionary <string, LineCapExtension>();
            var types = Altaxo.Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(LineCapExtension));

            foreach (var t in types)
            {
                var ex = (LineCapExtension)Activator.CreateInstance(t);
                _registeredStyles.Add(ex.Name, ex);
            }

            // now sort them by name
            var nameList = new List <string>(_registeredStyles.Keys);

            nameList.Remove(_defaultStyle.Name);
            nameList.Sort();
            nameList.Insert(0, _defaultStyle.Name);
            _registeredStylesSortedByName = new List <LineCapExtension>(nameList.Select(x => _registeredStyles[x]));
        }
Exemplo n.º 34
0
 private bool TryLoadCached()
 {
     bool bSuccess = false;
     string _cachedContent = string.Empty;
     try
     {
         ModuleCachingProvider cache = ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod());
         System.Collections.Generic.SortedDictionary<string, string> varyBy = new System.Collections.Generic.SortedDictionary<string, string>();
         varyBy.Add("locale", System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
         string cacheKey = cache.GenerateCacheKey(_ModuleConfiguration.TabModuleID, varyBy);
         byte[] cachedBytes =ModuleCachingProvider.Instance(_ModuleConfiguration.GetEffectiveCacheMethod()).GetModule(_ModuleConfiguration.TabModuleID, cacheKey);
         if (cachedBytes != null && cachedBytes.Length > 0)
         {
             _cachedContent = System.Text.Encoding.UTF8.GetString(cachedBytes);
             bSuccess = true;
         }
     }
     catch (Exception ex)
     {
         _cachedContent = string.Empty;
         bSuccess = false;
         ex.ToString();
     }
     if (bSuccess)
     {
         _Control = new CachedModuleControl(_cachedContent);
         this.Controls.Add(_Control);
     }
     return bSuccess;
 }
        private void AddOrUpdateTagData(CSLibrary.Structures.TagCallbackInfo info)
        {
            InvokeOnMainThread(() =>
            {
                bool found = false;
                int cnt;

                if (BleMvxApplication._rfMicro_Power == 4 && BleMvxApplication._config.RFID_PowerSequencing_NumberofPower != 0)
                {
                    currentPower = (BleMvxApplication._config.RFID_PowerSequencing_Level[info.antennaPort] / 10).ToString("0.0") + "dB";
                    RaisePropertyChanged(() => currentPower);
                }

                lock (TagInfoList)
                {
                    string epcstr = info.epc.ToString();

                    try
                    {
                        TagInfoListSpeedup.Add(epcstr, TagInfoList.Count);

                        RFMicroTagInfoViewModel item = new RFMicroTagInfoViewModel();

                        item.EPC      = info.epc.ToString();
                        item.NickName = GetNickName(item.EPC);
                        if (item.NickName != "")
                        {
                            item.DisplayName = item.NickName;
                        }
                        else
                        {
                            item.DisplayName = item.EPC;
                        }
                        item.RSSIColor  = "Black";
                        item.valueColor = "Black";
                        item.ScanValue  = info.Bank2Data[2].ToString();

                        switch (BleMvxApplication._rfMicro_SensorUnit)
                        {
                        case 0:
                            item.TemperatureValue = info.Bank2Data[4].ToString();
                            break;

                        case 2:
                            item.TemperatureValue = tempF(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                            break;

                        case 3:
                            item.TemperatureValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                            break;
                        }

                        item.OCRSSI = info.Bank2Data[3];

                        if (item.OCRSSI >= BleMvxApplication._rfMicro_minOCRSSI && item.OCRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
                        {
                            item.RSSIColor   = "Black";
                            item.SucessCount = 1;
                        }
                        else
                        {
                            item.RSSIColor   = "Red";
                            item.SucessCount = 0;
                        }

                        item.EPC        = "";
                        item.GOODOCRSSI = "";
                        item.NickName   = "";

                        TagInfoList.Insert(0, item);

                        _newtagCount4BeepSound++;
                        _newtagCount4Vibration++;
                        _newTagPerSecond++;

                        Trace.Message("EPC Data = {0}", item.EPC);
                    }
                    catch (Exception ex)
                    {
                        int index;

                        if (TagInfoListSpeedup.TryGetValue(epcstr, out index))
                        {
                            index = TagInfoList.Count - index;
                            index--;

                            TagInfoList[index].ScanValue = info.Bank2Data[2].ToString();

                            switch (BleMvxApplication._rfMicro_SensorUnit)
                            {
                            case 0:
                                TagInfoList[index].TemperatureValue = info.Bank2Data[4].ToString();
                                break;

                            case 2:
                                TagInfoList[index].TemperatureValue = tempF(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                                break;

                            case 3:
                                TagInfoList[index].TemperatureValue = temp(info.Bank2Data[4], info.Bank1Data[0], info.Bank1Data[1], info.Bank1Data[2], info.Bank1Data[3]).ToString("#0.0");
                                break;
                            }


                            TagInfoList[index].OCRSSI = info.Bank2Data[3];

                            if (TagInfoList[index].OCRSSI >= BleMvxApplication._rfMicro_minOCRSSI && TagInfoList[index].OCRSSI <= BleMvxApplication._rfMicro_maxOCRSSI)
                            {
                                TagInfoList[index].RSSIColor = "Black";
                                TagInfoList[index].SucessCount++;
                            }
                            else
                            {
                                TagInfoList[index].RSSIColor = "Red";
                            }
                        }
                        else
                        {
                            // error found epc
                        }
                    }
                }
            });
        }