public static string GetTableAlias(string tableName) { if (__tableNames == null) { DataSet _data = new DataSet(); _data.ReadXml(System.Configuration.ConfigurationManager.AppSettings["PathXMLAlias"]); __tableNames = new System.Collections.Hashtable(); foreach (DataRow row in _data.Tables[0].Rows) { if (!__tableNames.ContainsKey(row["name"].ToString().ToLower().Trim())) { __tableNames.Add(row["name"].ToString().ToLower().Trim(), row["alias"].ToString()); } } } if (__tableNames.ContainsKey(tableName)) { return __tableNames[tableName].ToString(); } return tableName; }
public bool ContainsDuplicate(int[] nums) { if (nums == null || nums.Length < 2) { return false; } System.Collections.Hashtable ht = new System.Collections.Hashtable(); bool result = false; for (int i = 0; i < nums.Length; i++) { if (!ht.ContainsKey(nums[i])) { ht.Add(nums[i], i); } else { result = true; break; } } return result; }
public static void CheckHits_(Query query, System.String defaultFieldName, Searcher searcher, int[] results, TestCase testCase) { Hits hits = searcher.Search(query); System.Collections.Hashtable correct = new System.Collections.Hashtable(); for (int i = 0; i < results.Length; i++) { correct.Add((System.Int32) results[i], null); } System.Collections.Hashtable actual = new System.Collections.Hashtable(); for (int i = 0; i < hits.Length(); i++) { actual.Add((System.Int32) hits.Id(i), null); } //Assert.AreEqual(correct, actual, query.ToString(defaultFieldName)); if (correct.Count != 0) { System.Collections.IDictionaryEnumerator iter = correct.GetEnumerator(); bool status = false; while (iter.MoveNext()) { status = actual.ContainsKey(iter.Key); if (status == false) break; } Assert.IsTrue(status, query.ToString(defaultFieldName)); } }
public int MajorityElement(int[] nums) { System.Collections.Hashtable ht = new System.Collections.Hashtable(); for (int i = 0; i < nums.Length; i++) { if (!ht.ContainsKey(nums[i])) { ht.Add(nums[i], 1); } else { ht[nums[i]] = (int)ht[nums[i]] + 1; } } foreach (System.Collections.DictionaryEntry item in ht) { if ((int)item.Value > nums.Length / 2) { return (int)item.Key; } } return 0; }
public Result Decode(BinaryBitmap image, System.Collections.Hashtable hints) { DecoderResult decoderResult; ResultPoint[] points; if (hints?.ContainsKey(DecodeHintType.PURE_BARCODE) == true) { BitMatrix bits = ExtractPureBits(image.BlackMatrix); decoderResult = Decoder.Decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image.BlackMatrix).Detect(hints); decoderResult = Decoder.Decode(detectorResult.Bits); points = detectorResult.Points; } Result result = new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.QR_CODE); if (decoderResult.ByteSegments != null) { result.PutMetadata(ResultMetadataType.BYTE_SEGMENTS, decoderResult.ByteSegments); } if (decoderResult.ECLevel != null) { result.PutMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.ECLevel.ToString()); } return(result); }
protected override System.Collections.Hashtable setDisplay(RemoteInterface.HC.FetchDeviceData[] devNames, int maxSegId, MegType megType) { System.Collections.Hashtable displayht = new System.Collections.Hashtable(); foreach (RemoteInterface.HC.FetchDeviceData dev in devNames) { if (!displayht.ContainsKey(dev.DevName)) { displayht.Add(dev.DevName, null); } } return displayht; }
public static string PerformWhois(string WhoisServerHost, int WhoisServerPort, string Host) { string result=""; try { String strDomain = Host; char[] chSplit = {'.'}; string[] arrDomain = strDomain.Split(chSplit); // There may only be exactly one domain name and one suffix if (arrDomain.Length != 2) { return ""; } // The suffix may only be 2 or 3 characters long int nLength = arrDomain[1].Length; if (nLength != 2 && nLength != 3) { return ""; } System.Collections.Hashtable table = new System.Collections.Hashtable(); table.Add("de", "whois.denic.de"); table.Add("be", "whois.dns.be"); table.Add("gov", "whois.nic.gov"); table.Add("mil", "whois.nic.mil"); String strServer = WhoisServerHost; if (table.ContainsKey(arrDomain[1])) { strServer = table[arrDomain[1]].ToString(); } else if (nLength == 2) { // 2-letter TLD's always default to RIPE in Europe strServer = "whois.ripe.net"; } System.Net.Sockets.TcpClient tcpc = new System.Net.Sockets.TcpClient (); tcpc.Connect(strServer, WhoisServerPort); String strDomain1 = Host+"\r\n"; Byte[] arrDomain1 = System.Text.Encoding.ASCII.GetBytes(strDomain1.ToCharArray()); System.IO.Stream s = tcpc.GetStream(); s.Write(arrDomain1, 0, strDomain1.Length); System.IO.StreamReader sr = new System.IO.StreamReader(tcpc.GetStream(), System.Text.Encoding.ASCII); System.Text.StringBuilder strBuilder = new System.Text.StringBuilder(); string strLine = null; while (null != (strLine = sr.ReadLine())) { strBuilder.Append(strLine+"\r\n"); } result = strBuilder.ToString(); tcpc.Close(); }catch(Exception exc) { result="Could not connect to WHOIS server!\r\n"+exc.ToString(); } return result; }
/// <summary> /// If the hashtable contains the key, the corresponding /// hashtable value is returned /// </summary> /// <param name="key">One of the graphical keys starting with GC_* /// </param> /// <returns></returns> public object GetGraphicAttribute(string key) { if (_GCSettings.ContainsKey(key)) { return(_GCSettings[key]); } else { return(null); } }
public object CustomFunction(int userId, string identifier, System.Collections.Hashtable input, out Library.DTO.Notification notification) { switch (identifier.ToLower()) { case "getdata": if (!input.ContainsKey("ID")) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Error, Message = "Unknow factory id" }; return(null); } return(bll.GetData(userId, Convert.ToInt32(input["ID"]), out notification)); case "getsearchfilter": return(bll.GetSearchFilter(userId, out notification)); case "getdetail": if (!input.ContainsKey("ID")) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Error, Message = "Unknow factory id" }; return(null); } return(bll.GetDetail(userId, Convert.ToInt32(input["ID"]), out notification)); case "getfactoryorderturnover": int pageSize = input.ContainsKey("PageSize") && input["PageSize"] != null && !string.IsNullOrEmpty(input["PageSize"].ToString()) ? Convert.ToInt32(input["PageSize"].ToString()) : 0; int pageIndex = input.ContainsKey("PageIndex") && input["PageIndex"] != null && !string.IsNullOrEmpty(input["PageIndex"].ToString()) ? Convert.ToInt32(input["PageIndex"].ToString()) : 0; string orderBy = input.ContainsKey("OrderBy") && input["OrderBy"] != null && !string.IsNullOrEmpty(input["OrderBy"].ToString()) ? input["OrderBy"].ToString() : null; string orderDirection = input.ContainsKey("OrderDirection") && input["OrderDirection"] != null && !string.IsNullOrEmpty(input["OrderDirection"].ToString()) ? input["OrderDirection"].ToString() : null; int totalRows = input.ContainsKey("TotalRows") && input["TotalRows"] != null && !string.IsNullOrEmpty(input["TotalRows"].ToString()) ? Convert.ToInt32(input["TotalRows"].ToString()) : 0; return(bll.GetFactoryOrderTurnover(userId, input, pageSize, pageIndex, orderBy, orderDirection, out totalRows, out notification)); case "exportexcelfactory": return(bll.ExportExcelFactory(userId, input, out notification)); case "getpersonincharge": return(bll.GetPersonInCharge(userId, input, out totalRows, out notification)); } notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Error, Message = "Custom function's identifier not matched" }; return(null); }
public WebServiceCaller(string webServiceURI, string webMethodName) : base() { this._webServiceURI = webServiceURI; this._webMethodName = webMethodName; string hashTableKey = this._webServiceURI + "/" + this._webMethodName; if (_webServiceWebMethodRequestFormats.ContainsKey(hashTableKey)) { this._requestFormat = (string)_webServiceWebMethodRequestFormats[hashTableKey]; } else { this._requestFormat = this.GetRequestFormat(); _webServiceWebMethodRequestFormats.Add(hashTableKey, this._requestFormat); } }
private Color GetColorByIDX(string personLookingAt, System.Collections.Hashtable hashy) { Color toUse; if (hashy.ContainsKey(personLookingAt)) { toUse = (Color)hashy[personLookingAt]; } else { // get a new color toUse = GetNextColor(hashy); hashy[personLookingAt] = toUse; } return(toUse); }
public object GetDetailProductionItemList(System.Collections.Hashtable filters, out Library.DTO.Notification notification) { List <DTO.DeliveryNoteDetailSearch> data = new List <DTO.DeliveryNoteDetailSearch>(); notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; var deliverynoteID = (filters.ContainsKey("deliveryNoteID") && filters["deliveryNoteID"] != null && !string.IsNullOrEmpty(filters["deliveryNoteID"].ToString())) ? Convert.ToInt32(filters["deliveryNoteID"].ToString()) : 0; using (var context = CreateContext()) { var dbItem = context.VanPhatMng_DeliveryNoteDetail_SearchView.Where(o => o.DeliveryNoteID == deliverynoteID).ToList(); data = converter.DB2DTO_GetListDetail(dbItem); } return(data); }
public static string TrackContent(string body, string domain, string dynamicEmailField, bool saveBat, string campaign, string oIdCampaign) { Campaign oCampaign = new Campaign(new Guid(oIdCampaign)); string newcontent = body; // Track content Regex oreg = new Regex(@"href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))"); MatchCollection Result = oreg.Matches(body); if (Result.Count > 0) // no need if no link { // track links System.Collections.Hashtable oNewLink = new System.Collections.Hashtable(); foreach (Match oMatsh in Result) { string oUrlTempo = Removehref(oMatsh.Value); string ext = oMatsh.Value.Substring(oMatsh.Value.Length - 4, 4).ToLower(); if ((ext != ".jpg") && (ext != ".gif") && (ext != ".jepg") && (ext != ".png") && (oMatsh.Value.IndexOf("mailto") < 0) && (oMatsh.Value.IndexOf("file") < 0)) { if (!oNewLink.ContainsKey(oUrlTempo)) { oNewLink.Add(oUrlTempo, null); } } } foreach (string okey in oNewLink.Keys) { string newlink = string.Format("https://{0}/Actions/o/{2}/?key={1}", domain, dynamicEmailField, TrackLink(oIdCampaign, okey).ToString()); newcontent = newcontent.Replace(okey, newlink); } } string endcontent = string.Empty; int endbodyposition = newcontent.ToLower().IndexOf("</body>"); // Add img before /body or at the end string TagImg = string.Format("<img src=\"https://{0}/Actions/op/{1}/?key={2}\" />", oCampaign.Domain, oIdCampaign, dynamicEmailField); string TagUnsubscribe = string.Format("<div>To unsubscribe and no longer receive our emails, please use <a href=\"https://{0}/Actions/Unsubscribe/{1}/?key={2}\" > this link</a>.</div>", oCampaign.Domain, oIdCampaign, dynamicEmailField); if (endbodyposition > 0) { endcontent = newcontent.Substring(0, endbodyposition - 1); endcontent = string.Concat(endcontent, TagUnsubscribe, TagImg, newcontent.Substring(endbodyposition, (newcontent.Length - (endbodyposition)))); } else { endcontent = string.Concat(newcontent, TagUnsubscribe, TagImg); } return(endcontent); }
public object CustomFunction(int userId, string identifier, System.Collections.Hashtable input, out Library.DTO.Notification notification) { switch (identifier.ToLower()) { case "getreportdataordered": if (!input.ContainsKey("season")) { throw new Exception("Unknow season"); } return(bll.GetExcelReportData(userId, input["season"].ToString(), out notification)); } notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Error, Message = "Custom function's identifier not matched" }; return(null); }
/// <summary> /// 移除重复票号 /// </summary> /// <returns></returns> public List <TicketNumInfo> MoveRepeatTicketNum(List <TicketNumInfo> TicketNumList) { System.Collections.Hashtable table = new System.Collections.Hashtable(); List <TicketNumInfo> m_TicketNumList = new List <TicketNumInfo>(); string key = ""; foreach (TicketNumInfo item in TicketNumList) { key = item.PasName + item.TicketNum.Replace("-", ""); if (!table.ContainsKey(key)) { table.Add(key, item); m_TicketNumList.Add(item); } } return(m_TicketNumList); }
public virtual void WriteEntry(string message, EventLogEntryType type, int eventID) { // Make Trace more readable by doing this: if (message.Length > 80) { message += '\n'; } if (type == EventLogEntryType.Error) { if (this.traceOnError) { Trace.WriteLine("ERROR: " + message); } } else if (type == EventLogEntryType.Warning) { if (this.traceOnWarning) { Trace.WriteLine("WARNING: " + message); } } else if (type == EventLogEntryType.Information) { if (this.traceOnInfo) { Trace.WriteLine("INFO: " + message); } } long lastTime = (timeTable.ContainsKey(eventID)) ? (long)timeTable[eventID] : 0; if (lastTime < (DateTime.Now.Ticks - ticksBetweenEntry)) { timeTable[eventID] = DateTime.Now.Ticks; try { eventLog.WriteEntry(message, type, eventID); } catch { // Write to isolated storage, so we can track failed eventlog writes } } }
public override SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; SearchFormData data = new SearchFormData(); data.Data = new List <PurchasingCalendarAppointmentSearchResultDTO>(); totalRows = 0; //try to get data try { using (PurchasingCalendarMngEntities context = CreateContext()) { string MeetingLocations = null; int Month = Convert.ToInt32(filters["month"]); int Year = Convert.ToInt32(filters["year"]); if (filters.ContainsKey("locations") && !string.IsNullOrEmpty(filters["locations"].ToString())) { MeetingLocations = string.Empty; foreach (int locationID in Newtonsoft.Json.JsonConvert.DeserializeObject <int[]>(filters["locations"].ToString().Replace("'", "''"))) { if (string.IsNullOrEmpty(MeetingLocations)) { MeetingLocations += locationID.ToString(); } else { MeetingLocations += "," + locationID.ToString();; } } } data.Data = converter.DB2DTO_AppointmentSearchResultDTOList(context.PurchasingCalendarMng_function_SearchPurchasingCalendarAppointment(MeetingLocations, Month, Year).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
private void button1_Click(object sender, EventArgs e) { //if (dgv存货档案.SelectedCells.Count != 0) //{ // MessageBox.Show(dgv存货档案.Rows.IndexOf(dgv存货档案.SelectedCells[0].OwningRow).ToString()); // //dgv存货档案.SelectedCells[0].OwningRow.; //} // 把乘号都变成大写 X string sql = "select ID, 存货代码 from 设置存货档案 "; DataTable dt = new DataTable("设置存货档案"); //""中的是表名 SqlDataAdapter da = new SqlDataAdapter(string.Format(sql, tb代码q.Text, tb名称q.Text), mySystem.Parameter.conn); SqlCommandBuilder cb = new SqlCommandBuilder(da); //da.Fill(dt); //foreach (DataRow dr in dt.Rows) //{ // if (dr["存货代码"].ToString().Contains("×")) // { // System.Console.WriteLine(dr["存货代码"].ToString().Replace("×", "X")); // dr["存货代码"] = dr["存货代码"].ToString().Replace("×", "X"); // } //} //da.Update(dt); // 去重 da.Fill(dt); System.Collections.Hashtable ht = new System.Collections.Hashtable(); foreach (DataRow dr in dt.Rows) { if (!ht.ContainsKey(dr["存货代码"])) { ht.Add(dr["存货代码"], 0); } int n = (int)ht[dr["存货代码"]]; ht[dr["存货代码"]] = n + 1; } foreach (Object h in ht.Keys) { int n = (int)ht[h]; if (n > 1) { System.Console.WriteLine(h.ToString()); System.Console.WriteLine(n); System.Console.WriteLine("*******"); } } }
private void FrmPatientFeeReport_Load(object sender, EventArgs e) { foreach (object obj in Enum.GetValues(typeof(StatDateType))) { cboDateType.Items.Add(obj.ToString( )); } cboDateType.Text = StatDateType.统计日.ToString( ); foreach (object obj in Enum.GetValues(typeof(OPDBillKind))) { cboInvoiceType.Items.Add(obj.ToString( )); } cboInvoiceType.SelectedIndex = 0; cboPatType.DisplayMember = "NAME"; cboPatType.ValueMember = "PATTYPECODE"; cboPatType.DataSource = BaseDataController.BaseDataSet[BaseDataCatalog.病人类型列表]; dtpFrom.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"); dtpEnd.Value = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59"); cboCharge.DisplayMember = "NAME"; cboCharge.ValueMember = "EMPLOYEE_ID"; cboCharge.DataSource = BaseDataController.BaseDataSet[BaseDataCatalog.人员列表]; cboDept.DisplayMember = "NAME"; cboDept.ValueMember = "DEPT_ID"; cboDept.DataSource = BaseDataController.BaseDataSet[BaseDataCatalog.科室列表].Select("MZ_FLAG=1 AND TYPE_CODE='001'").CopyToDataTable(); System.Collections.Hashtable htDoc = new System.Collections.Hashtable(); DataTable tb = BaseDataController.BaseDataSet[BaseDataCatalog.医生列表]; foreach (DataRow dr in tb.Rows) { if (!htDoc.ContainsKey(Convert.ToInt32(dr["EMPLOYEE_ID"]))) { htDoc.Add(Convert.ToInt32(dr["EMPLOYEE_ID"]), dr["EMP_NAME"].ToString().Trim()); } } foreach (object obj in htDoc) { cboDoc.Items.Add(((System.Collections.DictionaryEntry)obj).Value.ToString()); } }
/// <summary> /// HN5FZ开奖期号|开奖号 /// </summary> /// <returns></returns> public static List <string> HN5FZ(string issue) { if (!_dicLcItemUpd.ContainsKey($"HN5FZ_{issue}")) { string code = HN5FZ_my.Analysis(); _dicLcItemUpd[$"HN5FZ_{issue}"] = $"{issue}|{code}"; return(new List <string>() { $"{issue}|{code}" }); } else { return(null); } }
//iniitiate transactionDateAPI api public string transactionDateAPI(string merchant_email, string transaction_date) { System.Collections.Hashtable data = new System.Collections.Hashtable(); data.Add("key", Key); data.Add("merchant_email", merchant_email); data.Add("transaction_date", transaction_date); // generate hash string[] hashVarsSeq = "key|merchant_email|transaction_date".Split('|'); // spliting hash sequence from config string hash_string = ""; foreach (string hash_var in hashVarsSeq) { hash_string = hash_string + (data.ContainsKey(hash_var) ? data[hash_var].ToString() : ""); hash_string = hash_string + '|'; } hash_string += salt; // appending SALT gen_hash = Easebuzz_Generatehash512(hash_string).ToLower(); //generating hash data.Add("hash", gen_hash); string url = "https://dashboard.easebuzz.in/transaction/v1/retrieve/date"; var request = (HttpWebRequest)WebRequest.Create(url); var postData = "merchant_key=" + Key; postData += "&merchant_email=" + merchant_email; postData += "&transaction_date=" + transaction_date; postData += "&hash=" + gen_hash; var Ndata = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = Ndata.Length; using (var stream = request.GetRequestStream()) { stream.Write(Ndata, 0, Ndata.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); return(responseString); }
private void encodeBranch(Branch branch) { writer.writeUI8(branch.code); writer.writeUI16(2); int pos = writer.Pos; if (labels.ContainsKey(branch.target)) { // label came earlier writer.writeSI16(getLabelOffset(branch.target) - pos - 2); } else { // label comes later. don't know the offset yet. updates.Add(new UpdateEntry(pos + 2, pos, branch)); writer.writeSI16(0); } }
internal static System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldNames, IndexReader[] subReaders) { // maintain a unique set of field names System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < subReaders.Length; i++) { IndexReader reader = subReaders[i]; System.Collections.IEnumerator names = ((System.Collections.IDictionary)reader.GetFieldNames(fieldNames)).Keys.GetEnumerator(); while (names.MoveNext()) { if (!fieldSet.ContainsKey(names.Current)) { fieldSet.Add(names.Current, names.Current); } } } return(fieldSet); }
public BasicEnum(int v, string s, Type type) { Value = v; State = s; if (!_hash.ContainsKey(type)) { _hash.Add(type, new System.Collections.Hashtable()); } var isTable = _hash[type] as System.Collections.Hashtable; if (isTable.ContainsKey(v)) { throw new Exception("不能有重复的值"); } isTable.Add(v, this); System.IO.File.WriteAllLines("enum.txt", new string[] { s, type.ToString() }); }
public override System.Collections.ICollection GetIndexedFieldNames(bool storedTermVector) { // maintain a unique set of Field names System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < subReaders.Length; i++) { Monodoc.Lucene.Net.Index.IndexReader reader = subReaders[i]; System.Collections.ICollection names = reader.GetIndexedFieldNames(storedTermVector); foreach (object item in names) { if (fieldSet.ContainsKey(item) == false) { fieldSet.Add(item, item); } } } return(fieldSet); }
public void SetExecOrder(System.Collections.ArrayList alExecOrder, System.Collections.Hashtable hsPatient) { this.neuSpread1_Sheet1.Rows.Count = 0; int iRowIndex = 0; foreach (Neusoft.HISFC.Models.Order.ExecOrder info in alExecOrder) { Neusoft.HISFC.Models.RADT.PatientInfo p = null; if (hsPatient.ContainsKey(info.Order.Patient.ID)) { p = hsPatient[info.Order.Patient.ID] as Neusoft.HISFC.Models.RADT.PatientInfo; } else { p = info.Order.Patient; } this.neuSpread1_Sheet1.Rows.Add(iRowIndex, 1); this.neuSpread1_Sheet1.Cells[iRowIndex, 0].Text = "[" + p.PVisit.PatientLocation.Bed.ID + "]" + p.Name; Neusoft.HISFC.Models.Pharmacy.Item item = (Neusoft.HISFC.Models.Pharmacy.Item)info.Order.Item; //商品名称[规格] this.neuSpread1_Sheet1.Cells[iRowIndex, 1].Text = item.Name + "[" + item.Specs + "]"; //组标记 //每次量 this.neuSpread1_Sheet1.Cells[iRowIndex, 3].Text = info.Order.DoseOnce.ToString() + info.Order.DoseUnit; //频次 this.neuSpread1_Sheet1.Cells[iRowIndex, 4].Text = info.Order.Frequency.ID; //用法 this.neuSpread1_Sheet1.Cells[iRowIndex, 5].Text = info.Order.Usage.ID; //数量 this.neuSpread1_Sheet1.Cells[iRowIndex, 6].Text = info.Order.Qty.ToString() + info.Order.Unit; //备注 this.neuSpread1_Sheet1.Cells[iRowIndex, 7].Text = info.Memo; //组合号 this.neuSpread1_Sheet1.Cells[iRowIndex, 8].Text = info.Order.Combo.ID + info.DateUse.ToString(); iRowIndex++; } HISFC.Components.Order.Classes.Function.DrawCombo(this.neuSpread1_Sheet1, 8, 2); }
/** * Detects common bzip2 suffixes in the given filename. * * @param filename name of a file * @return <code>true</code> if the filename has a common bzip2 suffix, * <code>false</code> otherwise */ public static bool isCompressedFilename(String filename) { if (uncompressSuffix.Count == 0) { addToUncompressSuffix(); } String lower = filename.ToLower(System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag("en")); int n = lower.length(); // Shortest suffix is three letters (.bz), longest is five (.tbz2) for (int i = 3; i <= 5 && i < n; i++) { if (uncompressSuffix.ContainsKey(lower.Substring(n - i))) { return(true); } } return(false); }
/// <summary> /// 获得指定类型的默认值 /// </summary> /// <param name="ValueType">数据类型</param> /// <returns>默认值</returns> public static object GetDefaultValue(Type ValueType) { if (myDefaultValue == null) { myDefaultValue = new System.Collections.Hashtable(); myDefaultValue[typeof(object)] = null; myDefaultValue[typeof(byte)] = (byte)0; myDefaultValue[typeof(sbyte)] = (sbyte)0; myDefaultValue[typeof(short)] = (short)0; myDefaultValue[typeof(ushort)] = (ushort)0; myDefaultValue[typeof(int)] = (int)0; myDefaultValue[typeof(uint)] = (uint)0; myDefaultValue[typeof(long)] = (long)0; myDefaultValue[typeof(ulong)] = (ulong)0; myDefaultValue[typeof(char)] = (char)0; myDefaultValue[typeof(float)] = (float)0; myDefaultValue[typeof(double)] = (double)0; myDefaultValue[typeof(decimal)] = (decimal)0; myDefaultValue[typeof(bool)] = false; myDefaultValue[typeof(string)] = null; myDefaultValue[typeof(DateTime)] = DateTime.MinValue; myDefaultValue[typeof(System.Drawing.Point)] = System.Drawing.Point.Empty; myDefaultValue[typeof(System.Drawing.PointF)] = System.Drawing.PointF.Empty; myDefaultValue[typeof(System.Drawing.Size)] = System.Drawing.Size.Empty; myDefaultValue[typeof(System.Drawing.SizeF)] = System.Drawing.SizeF.Empty; myDefaultValue[typeof(System.Drawing.Rectangle)] = System.Drawing.Rectangle.Empty; myDefaultValue[typeof(System.Drawing.RectangleF)] = System.Drawing.RectangleF.Empty; myDefaultValue[typeof(System.Drawing.Color)] = System.Drawing.Color.Transparent; } if (ValueType == null) { throw new ArgumentNullException("ValueType"); } if (myDefaultValue.ContainsKey(ValueType)) { return(myDefaultValue[ValueType]); } if (ValueType.IsValueType) { return(System.Activator.CreateInstance(ValueType)); } return(null); }
/// <summary> /// This method simulates the random failure behavior which happens in real world. /// We will randomly select a message to fail based on some random number value. To make sure the message processing fails /// all the times during subsequent retries, we add the result to the hashtable and retrieve it from there. /// </summary> /// <param name="receivedMessage"></param> /// <returns></returns> private static bool ProcessOrder(BrokeredMessage receivedMessage) { if (hashTable.ContainsKey(receivedMessage.Properties["OrderNumber"])) { return(false); } if (new Random().Next() % 2 == 0 ? true : false) { Console.WriteLine("Received Order {0} with {1} number of items and {2} total", receivedMessage.Properties["OrderNumber"], receivedMessage.Properties["NumberOfItems"], receivedMessage.Properties["OrderTotal"]); return(true); } else { hashTable.Add(receivedMessage.Properties["OrderNumber"], false); return(false); } }
/// <summary> /// 获取配置工艺流程执行信息 /// </summary> /// <returns></returns> public static int GetProcessItemList(Control controlCollect, ref System.Collections.Hashtable hsProcess) { if (controlCollect.Controls.Count == 0 || controlCollect is Neusoft.FrameWork.WinForms.Controls.NeuComboBox) { if (hsProcess.ContainsKey(controlCollect.Name)) { Neusoft.HISFC.Models.Preparation.Process p = hsProcess[controlCollect.Name] as Neusoft.HISFC.Models.Preparation.Process; Function.GetProcessItem(controlCollect, ref p); } } else { foreach (Control c in controlCollect.Controls) { Function.GetProcessItemList(c, ref hsProcess); } } return(1); }
private void _mainWidget_Destroyed(object sender, EventArgs e) { textEditor.Document.LineChanged -= OnTextHasChanged; textEditor.TextArea.FocusInEvent -= OnTextBoxEnter; textEditor.TextArea.FocusOutEvent -= OnTextBoxLeave; _mainWidget.Destroyed -= _mainWidget_Destroyed; textEditor.TextArea.KeyPressEvent -= OnKeyPress; intellisense.ContextItemsNeeded -= ContextItemsNeeded; intellisense.ItemSelected -= InsertCompletionItemIntoTextBox; intellisense.LoseFocus -= HideCompletionWindow; intellisense.Cleanup(); // It's good practice to disconnect all event handlers, as it makes memory leaks // less likely. However, we may not "own" the event handlers, so how do we // know what to disconnect? // We can do this via reflection. Here's how it currently can be done in Gtk#. // Windows.Forms would do it differently. // This may break if Gtk# changes the way they implement event handlers. foreach (Widget w in Popup) { if (w is MenuItem) { PropertyInfo pi = w.GetType().GetProperty("AfterSignals", BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { System.Collections.Hashtable handlers = (System.Collections.Hashtable)pi.GetValue(w); if (handlers != null && handlers.ContainsKey("activate")) { EventHandler handler = (EventHandler)handlers["activate"]; (w as MenuItem).Activated -= handler; } } } } Popup.Destroy(); accel.Dispose(); textEditor.Destroy(); textEditor = null; _findForm.Destroy(); _owner = null; }
public static void generate(string langname, string root_dir_path) { create(); foreach (var doc_item in sates.core.doc_list.get_list()) { string doc_type; if (table.ContainsKey(doc_item.doc_type)) { doc_type = doc_item.doc_type; } else { doc_type = DEFAULT_GEN_NAME; } writer wr = (writer)table[doc_type]; wr.write(root_dir_path, doc_item, langname); } }
//------------------------------------------------------------------- public void Index(MemManager.Log.Log lg) { System.Collections.Hashtable cache = new System.Collections.Hashtable(4096); int processed = 0; System.Text.StringBuilder addresses = new System.Text.StringBuilder(); addresses.EnsureCapacity(32768); // Work out all unique addresses for (int i = 0; i < lg.Count; i++) { int index = lg[i].stackTraceString; if (index <= processed) continue; processed = index; string callstack = lg.GetString(index); string[] addrarray = callstack.Split(' '); foreach (string s in addrarray) { if (!cache.ContainsKey(s)) { cache[s] = s; addresses.Append(s); addresses.Append(' '); // Fix issue with nasty command line length issue on win32. if (addresses.Length >= 32000) { Index(addresses.ToString()); // Wipe addresses addresses = new System.Text.StringBuilder(); addresses.EnsureCapacity(32768); } } } } // Index unique addresses if (addresses.Length > 0) Index(addresses.ToString()); }
public Result decode(BinaryBitmap image, System.Collections.Hashtable hints) { DecoderResult decoderResult; ResultPoint[] points; if (hints != null && hints.ContainsKey(DecodeHintType.PURE_BARCODE)) { BitMatrix bits = extractPureBits(image); decoderResult = decoder.decode(bits); points = NO_POINTS; } else { DetectorResult detectorResult = new Detector(image).detect(); decoderResult = decoder.decode(detectorResult.Bits); points = detectorResult.Points; } return(new Result(decoderResult.Text, decoderResult.RawBytes, points, BarcodeFormat.PDF417)); }
/// <summary> /// Get a value from the class /// </summary> /// <param name="Key">The key from which to get the value</param> /// <param name="ValueName">The value name in the key</param> /// <returns>The value of the value name inside the key</returns> public string GetValue(string Key, string ValueName) { System.Collections.Hashtable KeyTable = (System.Collections.Hashtable)Keys[Key]; if (KeyTable != null) { if (KeyTable.ContainsKey(ValueName)) { return((string)KeyTable[ValueName]); } else { return(null); } } else { return(null); } }
private void ApplyItems(object[] items) { view.BeginUpdate(); try { System.Collections.Hashtable oldItems = new System.Collections.Hashtable(items.Length); foreach (ListViewItem viewItem in view.Items) { object key = GetKeyFromItem(viewItem.Tag); oldItems[key] = viewItem; } foreach (object item in items) { object key = GetKeyFromItem(item); if (oldItems.ContainsKey(key)) { ListViewItem viewItem = oldItems[key] as ListViewItem; UpdateListViewItem(viewItem, item); oldItems.Remove(key); } else { ListViewItem viewItem = new ListViewItem(); UpdateListViewItem(viewItem, item); view.Items.Add(viewItem); } } foreach (ListViewItem item in oldItems.Values) { view.Items.Remove(item); } view.Sort(); } finally { view.EndUpdate(); } }
public override System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldNames) { System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < readers.Count; i++) { IndexReader reader = ((IndexReader)readers[i]); System.Collections.ICollection names = reader.GetFieldNames(fieldNames); for (System.Collections.IEnumerator iterator = names.GetEnumerator(); iterator.MoveNext();) { System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry)iterator.Current; System.String s = fi.Key.ToString(); if (fieldSet.ContainsKey(s) == false) { fieldSet.Add(s, s); } } } return(fieldSet); }
object com_GetReaderData(DBConnect.DataType type, object reader) { if (type == DBConnect.DataType.Decorators) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; System.Collections.Hashtable decHT = new System.Collections.Hashtable(); for (int i = 0; i < dr.FieldCount; i++) { if (!decHT.ContainsKey(dr.GetName(i))) decHT.Add(dr.GetName(i), dr[i]); } return decHT; } else if (type == DBConnect.DataType.LaneCount) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; System.Collections.Hashtable laneCount = new System.Collections.Hashtable(); laneCount.Add(0, Convert.ToString(dr[2])); laneCount.Add(1, Convert.ToString(dr[3])); laneCount.Add(2, Convert.ToString(dr[4])); laneCount.Add(3, Convert.ToString(dr[5])); laneCount.Add(4, Convert.ToString(dr[6])); laneCount.Add(5, Convert.ToString(dr[7])); laneCount.Add(6, Convert.ToString(dr[8])); laneCount.Add(7, Convert.ToString(dr[9])); laneCount.Add(8, Convert.ToString(dr[10])); laneCount.Add(9, Convert.ToString(dr[11])); laneCount.Add(10, Convert.ToString(dr[12])); laneCount.Add(11, Convert.ToString(dr[13])); laneCount.Add(12, Convert.ToString(dr[14])); laneCount.Add(13, Convert.ToString(dr[15])); laneCount.Add(14, Convert.ToString(dr[16])); return laneCount; } else return null; }
private String partial1(String c) { System.Collections.Hashtable h = new System.Collections.Hashtable(); h.Add(" ", "11011001100"); h.Add("!", "11001101100"); h.Add("\"", "11001100110"); h.Add("#", "10010011000"); h.Add("$", "10010001100"); h.Add("%", "10001001100"); h.Add("&", "10011001000"); h.Add("'", "10011000100"); h.Add("(", "10001100100"); h.Add(")", "11001001000"); h.Add("*", "11001000100"); h.Add("+", "11000100100"); h.Add(",", "10110011100"); h.Add("-", "10011011100"); h.Add(".", "10011001110"); h.Add("/", "10111001100"); h.Add("0", "10011101100"); h.Add("1", "10011100110"); h.Add("2", "11001110010"); h.Add("3", "11001011100"); h.Add("4", "11001001110"); h.Add("5", "11011100100"); h.Add("6", "11001110100"); h.Add("7", "11101101110"); h.Add("8", "11101001100"); h.Add("9", "11100101100"); h.Add(":", "11100100110"); h.Add(";", "11101100100"); h.Add("<", "11100110100"); h.Add("=", "11100110010"); h.Add(">", "11011011000"); h.Add("?", "11011000110"); h.Add("@", "11000110110"); h.Add("A", "10100011000"); h.Add("B", "10001011000"); h.Add("C", "10001000110"); h.Add("D", "10110001000"); h.Add("E", "10001101000"); h.Add("F", "10001100010"); h.Add("G", "11010001000"); h.Add("H", "11000101000"); h.Add("I", "11000100010"); h.Add("J", "10110111000"); h.Add("K", "10110001110"); h.Add("L", "10001101110"); h.Add("M", "10111011000"); h.Add("N", "10111000110"); h.Add("O", "10001110110"); h.Add("P", "11101110110"); h.Add("Q", "11010001110"); h.Add("R", "11000101110"); h.Add("S", "11011101000"); h.Add("T", "11011100010"); h.Add("U", "11011101110"); h.Add("V", "11101011000"); h.Add("W", "11101000110"); h.Add("X", "11100010110"); h.Add("Y", "11101101000"); h.Add("Z", "11101100010"); h.Add("[", "11100011010"); h.Add(@"\", "11101111010"); h.Add("]", "11001000010"); h.Add("^", "11110001010"); h.Add("_", "10100110000"); h.Add("`", "10100001100"); h.Add("a", "10010110000"); h.Add("b", "10010000110"); h.Add("c", "10000101100"); h.Add("d", "10000100110"); h.Add("e", "10110010000"); h.Add("f", "10110000100"); h.Add("g", "10011010000"); h.Add("h", "10011000010"); h.Add("i", "10000110100"); h.Add("j", "10000110010"); h.Add("k", "11000010010"); h.Add("l", "11001010000"); h.Add("m", "11110111010"); h.Add("n", "11000010100"); h.Add("o", "10001111010"); h.Add("p", "10100111100"); h.Add("q", "10010111100"); h.Add("r", "10010011110"); h.Add("s", "10111100100"); h.Add("t", "10011110100"); h.Add("u", "10011110010"); h.Add("v", "11110100100"); h.Add("w", "11110010100"); h.Add("x", "11110010010"); h.Add("y", "11011011110"); h.Add("z", "11011110110"); h.Add("{", "11110110110"); h.Add("|", "10101111000"); h.Add("}", "10100011110"); h.Add("~", "10001011110"); if (h.ContainsKey(c) == true) { return h[c].ToString(); } return null; }
/// <summary> /// Method LoadViews() /// </summary> //protected override void LoadViews() public void LoadViews() { this.views = new Collection<View>(); System.Collections.Hashtable RelatedViews = new System.Collections.Hashtable(); DataTable viewsTable = GetViewsAsDataTable(); foreach (DataRow viewRow in viewsTable.Rows) { View V = new Epi2000.View(viewRow, this); // set the is related view attribute IDataReader R = this.collectedData.GetTableDataReader(V.Name); while(R.Read()) { if (R["Name"].ToString().ToUpper().StartsWith("RELVIEW")) { if(! RelatedViews.ContainsKey(R["DataTable"].ToString())) { RelatedViews.Add(R["DataTable"].ToString(), R["DataTable"].ToString()); } } } R.Close(); this.views.Add(V); } foreach(Epi2000.View V in this.views) { if (RelatedViews.ContainsKey(V.Name)) { V.IsRelatedView = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["userID"] == null) { // Redirect user to login before doing anything else Response.Redirect("~/Login.aspx?redirect=MyAccount.aspx"); } else { String myConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; SqlConnection myConnection = new SqlConnection(myConnectionString); try { myConnection.Open(); /** * Find default address */ SqlCommand cmd = new SqlCommand("Select * from [GadgetFox].[dbo].[Addresses], [GadgetFox].[dbo].[ZipCodes] where Addresses.Zip = ZipCodes.Zip and EmailID=@EmailID and IsProfileAddress=@IsProfileAddress", myConnection); cmd.Parameters.AddWithValue("@EmailID", Session["userID"].ToString()); cmd.Parameters.AddWithValue("@IsProfileAddress", true); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { addressLB.Text = dr["Address Line1"].ToString() + "<br/>"; if (dr["Address Line2"].ToString().Length > 0) addressLB.Text += dr["Address Line2"].ToString() + "<br/>"; addressLB.Text += dr["City"].ToString() + ", " + dr["State"].ToString() + " " + dr["Zip"].ToString(); } dr.Close(); /** * Find first and last name */ SqlCommand cmd2 = new SqlCommand("Select * from [GadgetFox].[dbo].[Users] where EmailID=@EmailID", myConnection); cmd2.Parameters.AddWithValue("@EmailID", Session["userID"].ToString()); SqlDataReader dr2 = cmd2.ExecuteReader(); if (dr2.Read()) { nameLB.Text = dr2["FirstName"].ToString() + " " + dr2["LastName"].ToString(); birthdayLB.Text = DateTime.Parse(dr2["DOB"].ToString()).ToShortDateString(); } dr2.Close(); /** * Find default credit card */ SqlCommand cmd3 = new SqlCommand("Select * from [GadgetFox].[dbo].[CCDetails] where EmailID=@EmailID", myConnection); cmd3.Parameters.AddWithValue("@EmailID", Session["userID"].ToString()); SqlDataReader dr3 = cmd3.ExecuteReader(); if (dr3.Read()) { // Only display last 4 digits String ccType = dr3["CCType"].ToString(); String ccNum = dr3["CCNum"].ToString(); ccLB.Text = ccType + " ****" + ccNum.Substring(ccNum.Length - 4, 4); ccExpDateLB.Text = dr3["ExpMonth"].ToString() + "/" + dr3["ExpYear"].ToString(); } dr3.Close(); /** * Find product orders */ DataTable Table1 = new DataTable("MyOrders"); DataRow Row1 = Table1.NewRow(); SqlCommand cmd4 = new SqlCommand("select * from vw_CustomerOrders where EmailID=@EmailID", myConnection); //define SQL query cmd4.Parameters.AddWithValue("@EmailID", Session["userID"]); SqlDataReader dr4 = cmd4.ExecuteReader(); // Add colums for each field into the table // EmailID, ProductID, Name, Price, SalePrice, InSale, ImageID, ImageData DataColumn oid = new DataColumn("Order ID"); DataColumn status = new DataColumn("Status"); DataColumn purchaseDate = new DataColumn("Purchase Date"); DataColumn products = new DataColumn("Products"); DataColumn tracking = new DataColumn("Tracking #"); DataColumn total = new DataColumn("Total"); DataColumn actions = new DataColumn("#"); oid.DataType = System.Type.GetType("System.String"); status.DataType = System.Type.GetType("System.String"); purchaseDate.DataType = System.Type.GetType("System.String"); products.DataType = System.Type.GetType("System.String"); tracking.DataType = System.Type.GetType("System.String"); total.DataType = System.Type.GetType("System.String"); actions.DataType = System.Type.GetType("System.String"); Table1.Columns.Add(oid); Table1.Columns.Add(status); Table1.Columns.Add(purchaseDate); Table1.Columns.Add(products); Table1.Columns.Add(tracking); Table1.Columns.Add(total); Table1.Columns.Add(actions); int orderId = -1; System.Collections.Hashtable orders = new System.Collections.Hashtable(); while (dr4.Read()) { orderId = int.Parse(dr4["OrderID"].ToString()); // Add row when a new order is encountered if (!orders.ContainsKey(orderId)) { orders[orderId] += dr4["Quantity"].ToString() + "x " + dr4["Name"].ToString() + ". "; Row1 = Table1.NewRow(); Table1.Rows.Add(Row1); // Insert values into the row from the query Row1["Order ID"] = dr4["OrderID"]; Row1["Status"] = dr4["Status"]; Row1["Purchase Date"] = DateTime.Parse(dr4["PurchaseDate"].ToString()).ToShortDateString(); Row1["Products"] = orders[orderId]; Row1["Tracking #"] = dr4["TrackingID"]; Row1["Total"] = "$" + string.Format("{0:$#,###.##}", dr4["OrderTotal"].ToString()); // Columns to purchase item Row1["#"] = ""; // For cancel order } else { orders[orderId] += dr4["Quantity"].ToString() + "x " + dr4["Name"].ToString() + ". "; Row1["Products"] = orders[orderId]; } } // Add last order dr4.Close(); GridView1.DataSource = Table1; GridView1.DataBind(); } catch (SqlException ex) { Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + ex.Message + "')</SCRIPT>"); } finally { myConnection.Close(); } } } }
private static void updateMysql(StringBuilder str, Assembly assembly, Type baseEntityType) { foreach (Type entityType in assembly.GetTypes()) { bool Table = true; if (entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), false).Length > 0) { object obje = (EntityDefinitionAttribute)entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), false)[0]; Table = ((EntityDefinitionAttribute)obje).IsTable; } if (!entityType.IsClass || !entityType.IsSubclassOf(baseEntityType) || entityType.IsGenericType || entityType.Name.Contains("<") || !Table) continue; PropertyInfo[] props = PersistenceStrategyProvider.FindStrategyFor(entityType) .GetPersistentProperties(entityType); object[] memberinfo=entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), true); string className = entityType.Name; if (TableExistMy(className, Transaction.Instance.GetSchema())) { DataTable table = executeSql("select * from " + className + " where Id=-1"); DataTable metaTable = Transaction.Instance.MetaTableColumns(className); Dictionary<string, int> metaLengths = new Dictionary<string, int>(); foreach (DataRow row in metaTable.Rows) { if ((string)row["DATA_TYPE"] != "varchar") continue; metaLengths[(string)row["COLUMN_NAME"]] = Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]); } System.Collections.Hashtable fieldDictionary = new System.Collections.Hashtable(); foreach (PropertyInfo property in props) { //Derviş Aygün FieldDefinitionAttribute fielddefinition = ReflectionHelper.GetAttribute<FieldDefinitionAttribute>(property); if (fielddefinition != null && fielddefinition.MappingType == FieldMappingType.No) continue; //Derviş aygün FieldDefinitionAttribute definition = DataDictionary.Instance.GetFieldDefinition(className + "." + property.Name); string fieldname = (property.PropertyType.IsSubclassOf(baseEntityType)) ? definition.Name + "_Id" : definition.Name; fieldDictionary[fieldname] = 1; if (!table.Columns.Contains(fieldname)) { string sql = "alter table " + className + " add " + fieldname + " " + MapTypeMysql(definition); executeNonQuery(sql); str.Append("New Field: " + fieldname + ", Table: " + className + "<br/>"); } else if (!fieldname.EndsWith("_Id") && definition.TypeName != "Boolean" && table.Columns[fieldname].DataType.Name != definition.TypeName) { string sql = "alter table " + className + " modify column " + fieldname + " " + MapTypeMysql(definition); executeNonQuery(sql); str.Append("Alter Field: " + fieldname + ", Table: " + className + "<br/>"); } else if (!fieldname.EndsWith("_Id") && definition.TypeName == "Boolean" && table.Columns[fieldname].DataType.Name != "SByte") { string sql = "alter table " + className + " modify column " + fieldname + " " + MapTypeMysql(definition); executeNonQuery(sql); str.Append("Alter Field: " + fieldname + ", Table: " + className + "<br/>"); } else if (metaLengths.ContainsKey(fieldname) && definition.Length != metaLengths[fieldname]) { string sql = "alter table " + className + " modify column " + fieldname + " " + MapTypeMysql(definition); executeNonQuery(sql); str.Append("Resize Field: " + fieldname + ", Table: " + className + ", Length: " + definition.Length + "<br/>"); } } foreach (DataColumn column in table.Columns) { if (!fieldDictionary.ContainsKey(column.ColumnName)) { string sql = "alter table " + className + " drop column " + column.ColumnName; executeNonQuery(sql); str.Append("Drop Field: " + column.ColumnName + ", Table: " + className + "<br/>"); } } } else { //Hiç özelliği olmayan class lar olabilir if (props.Length == 0) { continue; } StringBuilder s = new System.Text.StringBuilder(); s.Append("CREATE TABLE " + className + " ("); string pkstr = ""; foreach (PropertyInfo property in props) { FieldDefinitionAttribute definition = DataDictionary.Instance.GetFieldDefinition(className + "." + property.Name); string fieldname = (property.PropertyType.IsSubclassOf(baseEntityType)) ? definition.Name + "_Id" : definition.Name; s.Append("`" + fieldname + "` " + MapTypeMysql(definition)); if (definition.Name == "Id") { if (memberinfo != null && memberinfo.Length > 0) { EntityDefinitionAttribute attirebute = (EntityDefinitionAttribute)memberinfo[0]; if(attirebute.IdMethod==IdMethod.UserSubmitted) s.Append(" NOT NULL "); } else s.Append(" NOT NULL AUTO_INCREMENT"); pkstr = " ,PRIMARY KEY (`Id`)"; } s.Append(", "); } s.Remove(s.Length - 2, 2); s.Append(pkstr); s.Append(")"); string sql = s.ToString(); executeNonQuery(sql); str.Append("New Table: " + className + "<br/>"); } } }
private String partial1(String c) { System.Collections.Hashtable h = new System.Collections.Hashtable(); h.Add(" ", "11011001100"); h.Add("!", "11001101100"); h.Add("\"", "11001100110"); h.Add("#", "10010011000"); h.Add("$", "10010001100"); h.Add("%", "10001001100"); h.Add("&", "10011001000"); h.Add("'", "10011000100"); h.Add("(", "10001100100"); h.Add(")", "11001001000"); h.Add("*", "11001000100"); h.Add("+", "11000100100"); h.Add(",", "10110011100"); h.Add("-", "10011011100"); h.Add(".", "10011001110"); h.Add("/", "10111001100"); h.Add("0", "10011101100"); h.Add("1", "10011100110"); h.Add("2", "11001110010"); h.Add("3", "11001011100"); h.Add("4", "11001001110"); h.Add("5", "11011100100"); h.Add("6", "11001110100"); h.Add("7", "11101101110"); h.Add("8", "11101001100"); h.Add("9", "11100101100"); h.Add(":", "11100100110"); h.Add(";", "11101100100"); h.Add("<", "11100110100"); h.Add("=", "11100110010"); h.Add(">", "11011011000"); h.Add("?", "11011000110"); h.Add("@", "11000110110"); h.Add("A", "10100011000"); h.Add("B", "10001011000"); h.Add("C", "10001000110"); h.Add("D", "10110001000"); h.Add("E", "10001101000"); h.Add("F", "10001100010"); h.Add("G", "11010001000"); h.Add("H", "11000101000"); h.Add("I", "11000100010"); h.Add("J", "10110111000"); h.Add("K", "10110001110"); h.Add("L", "10001101110"); h.Add("M", "10111011000"); h.Add("N", "10111000110"); h.Add("O", "10001110110"); h.Add("P", "11101110110"); h.Add("Q", "11010001110"); h.Add("R", "11000101110"); h.Add("S", "11011101000"); h.Add("T", "11011100010"); h.Add("U", "11011101110"); h.Add("V", "11101011000"); h.Add("W", "11101000110"); h.Add("X", "11100010110"); h.Add("Y", "11101101000"); h.Add("Z", "11101100010"); h.Add("[", "11100011010"); h.Add(@"\", "11101111010"); h.Add("]", "11001000010"); h.Add("^", "11110001010"); h.Add("_", "10100110000"); if (h.ContainsKey(c) == true) { return h[c].ToString(); } return null; }
object dbCmd_GetReaderData(DataType type, object reader) { if (type == DataType.SysAlarmLog) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; try { InsertCommand cmd = GetInsertCmd.setIIPEventCmd(dr); dbCmd.insert(cmd); //ServerMeg.setServerMeg("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent"); //if (InsertEvent != null) //{ // InsertEvent(cmd.RspID); //} } catch //(System.Exception ex) { //ServerMeg.setAlarmMeg("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent���~!!"); throw new Exception("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent���~!!"); } } else if (type == DataType.IIPEvent) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; //if (InsertEvent != null) //{ // InsertEvent(dr[0].ToString()); //} } else if (type == DataType.EventID) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; return dr[0]; } else if (type == DataType.Renew) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; System.Collections.Hashtable ht = new System.Collections.Hashtable(); for (int i = 0; i < dr.FieldCount; i++) { if (!ht.ContainsKey(dr.GetName(i))) ht.Add(dr.GetName(i), dr[i]); } return ht; } else if (type == DataType.AllMoveEvent) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; return new MoveData(Convert.ToInt32(dr[39]), dr[16].ToString(), DateTime.Parse(dr[13].ToString()), dr[6].ToString(), dr[7].ToString(), Convert.ToInt32(dr[10]), Convert.ToInt32(dr[11]), dr[25].ToString()); } return null; }
private void ApplyItems (object[] items) { view.BeginUpdate (); try { System.Collections.Hashtable oldItems = new System.Collections.Hashtable (items.Length); foreach (ListViewItem viewItem in view.Items) { object key = GetKeyFromItem (viewItem.Tag); oldItems[key] = viewItem; } foreach (object item in items) { object key = GetKeyFromItem (item); if (oldItems.ContainsKey (key)) { ListViewItem viewItem = oldItems[key] as ListViewItem; UpdateListViewItem (viewItem, item); oldItems.Remove (key); } else { ListViewItem viewItem = new ListViewItem (); UpdateListViewItem (viewItem, item); view.Items.Add (viewItem); } } foreach (ListViewItem item in oldItems.Values) view.Items.Remove (item); view.Sort (); } finally { view.EndUpdate (); } }
/// <summary> /// Was orginally used to update the database with any changed values /// /// Roadmap: /// 1. Create Variables to hold Splits that have actuall changed /// i. SplitsToDrop Contain splits that are in the allocation_provider table that have been /// determined to be old/outdated/incorrect or need changed. /// ii. SplitsToWrite Contain the splits that need to be written to allocation_provider table /// 2. Grab all entries from allocation_provider /// i. dt2_AllocTbl a datatable of the split items as they exist in the allocation_provider table /// ii. htCurrentRecord a hashtable that is used to determine if the recorded data matches the data in this objects payment ledger items /// Also used to determine if entries exist that are no longer a part of opendental. (meaning they have been deleted) /// 3. Cycle through this.Payments compare to entries of allocation_provider /// i. Add to SplitsToDrop and SplitsToWrite as appropriate /// a. Checks split count to match /// b. Checks provider count to match /// c. Calcuates provider balances to match (for the split entries only) /// d. If different drop and write (as indicated in 3.i. ) else leave alone /// ii. Marke htCurrentRecord items as "used" if there is an ODEntry corresponding to the record. /// 4. Delete entries not used in htCurrentRecord (ie data that has been deleted from OpenDental) /// i. makes use of the key values in htCurrentRecord /// ii. key = [tablenum]-[tableitemnum] /// 5. Delete and add entries that are in the SplitsToDrop,SplitsToWrite lists /// /// </summary> private bool Update2() { bool rVal_Successful = true; 1.ToString(); // Just to break and inspect //PU.MB = "Method not implemented. Not Saving Provider Paysplit Data\n\n" + PU.Method; List<PP_PaymentItem> SplitsToDrop = new List<PP_PaymentItem>(); // Drop entries that will be needing updating List<PP_PaymentItem> SplitsToWrite = new List<PP_PaymentItem>(); // Write all newly allocated splits and any changed entries. /////////////////////////////////////////////////////////////////////////////// // Find all the payments in the split table currently /////////////////////////////////////////////////////////////////////////////// string cmd2 = "SELECT PayTableSource, PaySourceNum, IsFullyAllocated, Amount, ProvNum FROM " + MyAllocator1_ProviderPayment.TABLENAME + "\nWHERE Guarantor = " + this.GUARANTOR_NUMBER; DataTable dt2_AllocTbl = Db.GetTableOld(cmd2); System.Collections.Hashtable htCurrentRecord = new System.Collections.Hashtable(); for(int i = 0;i < dt2_AllocTbl.Rows.Count;i++) { // key = [tablesource as int]-[SourceNum] string key = dt2_AllocTbl.Rows[i][0].ToString() + "-" + dt2_AllocTbl.Rows[i][1].ToString(); //if (key == "5-6160") // 1.ToString(); if(!htCurrentRecord.ContainsKey(key)) htCurrentRecord[key] = "notused"; } // Roadmap -- Check to see if payment key matches pulled string. // See if splits are recorded // Add splits to SPlitsToWrite // What will be the distinguishing factor between unrecorded and recorded. /// 1. Existence of TableSource-SourceNum. If exists then it has been written. If not then has not. /// 2. If Recorded ProvNum = 0 then split is considered unallocated. /// 3. Need to check if any of the items in payment list have splits = 0; /// /// Or /// Recreate Payment Items /// Check every one for differences. /// Write every one. /// /// I think the final decision is /// 1. Write non existant entries /// 2. Only update entries that have provNum =0 /// 3. Make the de-allocator delete the entries or update to ProvNum = 0; /// -- Equalizer is not supposed to change existing allocations. // if (htCurrentRecord.Count != 0) for(int i = 0;i < this.Payments.Count;i++) { // DataTable dtv1 = ViewLedgerObject(new LedgerItemTypes[] { LedgerItemTypes.Payment }); //if (this.Payments[i].PROCNUM == 161218) // 1.ToString(); string key = ((int)this.Payments[i].OD_TABLESOURCE).ToString() + "-" + this.Payments[i].PROCNUM; if(!htCurrentRecord.ContainsKey(key)) // if key does not exist then has not been written. { SplitsToWrite.Add(this.Payments[i]); } else { // Key does exist--meaning a record is recorded in the alloctable for this table and item num htCurrentRecord[key] = "used"; // see if any of these records have provider = 0 string subsetCondition = "PayTableSource="+ ((int)this.Payments[i].OD_TABLESOURCE).ToString() + " AND PaySourceNum=" + this.Payments[i].PROCNUM.ToString(); DataRow[] draSubSet = dt2_AllocTbl.Select(subsetCondition); // Find split that matches subset item // does subset have ProvNum = 0? // do we delete all subset entries =0 && AllocateAs in this.Payments? // What signifies difference // 1. Different number of split entries // 2. If some any of entries have different ProvNum, ItemNum, Amount // Draw back of this approach is that any payment that is partially allocated will // be droped and reallocated. Could make a difference. But getting around this // is another programing logical issue. // Accept the compromise: // Another Question am I using the IsFullyAllocated Flag effectively? Wouldn't ProvNum != 0 // Mean the same thing? Or ProvNum =0 give contion to find Flag. Probably so but logically // it seems to fit in the puzzle so I am leaving it for now. Plus for the most part // the Equailizer should equalize the payments equally for the most part. if(draSubSet.Length == Payments[i].PAYMENT_SPLITS.Count) //same number of splits { // check for matches. // Does Provider Count Match? List<int> ProvsInPayments = new List<int>(); List<decimal> ProvsInPayments_Balances = new List<decimal>(); List<int> ProvsInSubSet = new List<int>(); List<decimal> ProvsInSubSet_Balances = new List<decimal>(); // Find the Provider Balances in Payments[i] add to ProvsInPayments_Balances for(int j = 0;j < Payments[i].PAYMENT_SPLITS.Count;j++) { int Provider1 = Payments[i].PAYMENT_SPLITS[j].PROVNUM; if(ProvsInPayments.Contains(Provider1)) ProvsInPayments_Balances[ProvsInPayments.IndexOf(Provider1)] += Payments[i].PAYMENT_SPLITS[j].AMMOUNT; else { ProvsInPayments.Add(Provider1); ProvsInPayments_Balances.Add(0); ProvsInPayments_Balances[ProvsInPayments.IndexOf(Provider1)] += Payments[i].PAYMENT_SPLITS[j].AMMOUNT; } } // Find the Provider Balances Recorde in table associated with single payment entry for(int k = 0;k < draSubSet.Length;k++) { int provider2 = (int)draSubSet[k][4]; decimal amount = (decimal)draSubSet[k][3]; if(ProvsInSubSet.Contains(provider2)) ProvsInSubSet_Balances[ProvsInSubSet.IndexOf(provider2)] += amount; else { ProvsInSubSet.Add(provider2); ProvsInSubSet_Balances.Add(0); ProvsInSubSet_Balances[ProvsInSubSet.IndexOf(provider2)] += amount; } } // Determine if they are an exact match // 1. Split Count // 2. Provider balances are the same bool ExactMatch = ProvsInPayments.Count == ProvsInSubSet.Count; // (don't add Payment to drop/write list) if(ExactMatch) { for(int k = 0;k < ProvsInPayments.Count;k++) { int providerInQuestion = ProvsInPayments[k]; if(ProvsInSubSet.Contains(providerInQuestion) && ProvsInPayments.Contains(providerInQuestion)) ExactMatch = ExactMatch && ProvsInPayments_Balances[ProvsInPayments.IndexOf(providerInQuestion)] == ProvsInSubSet_Balances[ProvsInSubSet.IndexOf(providerInQuestion)]; else ExactMatch = false; if(!ExactMatch) k = ProvsInPayments.Count; } } if(!ExactMatch) { SplitsToDrop.Add(this.Payments[i]); SplitsToWrite.Add(this.Payments[i]); } // Note if it is an exact match then don't add the payment to the write list. Just keep what // is in the database. } // end if (draSubSet.Length == Payments[i].PAYMENT_SPLITS.Count) else // split length does not match { SplitsToDrop.Add(this.Payments[i]); SplitsToWrite.Add(this.Payments[i]); } }// end else }// end for (int i = 0; i < this.Payments.Count; i++) #region Delete Items in allocation_provider table that data doesn't exist for in opendental tables // Find all the unused items in htCurrentRecord. These indicate that OD had no data for // the items that were in the allocation provider table. List<string> keys2Delete = new List<string>(); foreach(System.Collections.DictionaryEntry de in htCurrentRecord) { string key2 = de.Key.ToString(); if(de.Value.ToString() == "notused") keys2Delete.Add(key2); } //for (int i = 0; i < htCurrentRecord.Keys.Count; i++) //{ // string key2 = htCurrentRecord[ htCurrentRecord.Keys.i]]; // if (htCurrentRecord[key2].ToString() == "notused") // keys2Delete.Add(key2); //} try { if(keys2Delete.Count != 0) { string dropUnusedCommand = "DELETE FROM " + MyAllocator1_ProviderPayment.TABLENAME + " WHERE "; for(int i = 0;i < keys2Delete.Count;i++) { string[] splitme = keys2Delete[i].Split(new char[] { '-' }); LedgerItemTypes TableSource = (LedgerItemTypes)Int32.Parse(splitme[0]); ulong SourceNum = ulong.Parse(splitme[1]); dropUnusedCommand += "( PayTableSource = " + TableSource + " AND " + " PaySourceNum = " + SourceNum + ")"; if(i < keys2Delete.Count - 1) dropUnusedCommand += "\nOR "; } Db.NonQOld(dropUnusedCommand); } } catch(Exception exc) { string s2 = exc.ToString(); } #endregion //Write the subset lists to DataBase try { string cmd = ""; // Do Required Drops First. These are drops where the allocation has physically changed. if(SplitsToDrop.Count != 0) { cmd = "DELETE FROM " + MyAllocator1_ProviderPayment.TABLENAME + " WHERE \n"; for(int i = 0;i < SplitsToDrop.Count;i++) { cmd += "( PayTableSource = " + ((int)SplitsToDrop[i].OD_TABLESOURCE).ToString() + " AND " + " PaySourceNum = " + SplitsToDrop[i].PROCNUM + ")"; if(i < SplitsToDrop.Count - 1) cmd += "\nOR "; } Db.NonQOld(cmd); } // Add Spilt to AllocationTable if(SplitsToWrite.Count != 0) { cmd = MyAllocator1_ProviderPayment.ValueStringHeader() + "\n"; // Header // (AllocType, Guarantor, ProvNum, " //+ "PayTableSource, PaySourceNum, AllocToTableSource, AllocToSourceNum, Amount, IsFullyAllocated) for(int i = 0;i < SplitsToWrite.Count;i++) { //if (SplitsToWrite[i].PROCNUM == 169218) // 1.ToString(); for(int j = 0;j < SplitsToWrite[i].PAYMENT_SPLITS.Count;j++) { cmd += MyAllocator1_ProviderPayment.ValueString( MyAllocator1_ProviderPayment.AllocationTypeID, // AllocType SplitsToWrite[i].GUARANTOR, // Guarantor SplitsToWrite[i].PAYMENT_SPLITS[j].PROVNUM, // ProvNum ((int)SplitsToWrite[i].OD_TABLESOURCE), // PayTableSource SplitsToWrite[i].PROCNUM, // PaySourceNum ((int)SplitsToWrite[i].PAYMENT_SPLITS[j].ALLOCATED_FROM_TABLE), //AllocToTableSource SplitsToWrite[i].PAYMENT_SPLITS[j].ALLOCATED_FROM_NUM, //AllocToSourceNum SplitsToWrite[i].PAYMENT_SPLITS[j].AMMOUNT, //Amount SplitsToWrite[i].IS_ALLOCATED); //IsFullyAllocated if(j < SplitsToWrite[i].PAYMENT_SPLITS.Count - 1) cmd += " , \n "; } if(i < SplitsToWrite.Count - 1 && SplitsToWrite[i].PAYMENT_SPLITS.Count != 0) cmd += " , \n "; } Db.NonQOld(cmd); } } catch(Exception exc) { PU.MB = "Error in ProviderAllocation\nMessage: " + exc.Message + "\nMethod: " + PU.Method; rVal_Successful = false; } return rVal_Successful; }
/// <summary> /// Generates a Summary Table Outlining the Provider Charges and Revenues /// Illustrating Unearned Income /// use MinDate and MaxDate to flag all dates /// </summary> public static DataTable GenerateSummaryTable(int Guarantor,DateTime dtFrom, DateTime dtTo) { DataTable rValReturnTable = null; DataTable dtProviderBalance = Db.GetTableOld(ProviderRevenueByGuarantor(Guarantor,dtFrom,dtTo)); DataTable dtProvAbbr = Db.GetTableOld("SELECT ProvNum, Abbr FROM Provider"); if (dtProviderBalance != null && dtProviderBalance.Rows.Count != 0) { // Get Provider Abbreviations System.Collections.Hashtable htAllProvs = new System.Collections.Hashtable(); for (int i = 0; i < dtProvAbbr.Rows.Count; i++) if (!htAllProvs.ContainsKey(dtProvAbbr.Rows[i][0].ToString())) htAllProvs[dtProvAbbr.Rows[i][0].ToString()] = dtProvAbbr.Rows[i][1].ToString(); if (!htAllProvs.ContainsKey("0")) htAllProvs["0"] = "Unearned"; // First establish a list of providers System.Collections.ArrayList alProvs = new System.Collections.ArrayList(); for (int i = 0; i < dtProviderBalance.Rows.Count; i++) if (!alProvs.Contains(dtProviderBalance.Rows[i][0].ToString())) alProvs.Add(dtProviderBalance.Rows[i][0].ToString()); // Fill and Create DataTable DataTable dtBalancesTable = new DataTable(); dtBalancesTable.Columns.Add(new DataColumn("Provider", typeof(string))); dtBalancesTable.Columns.Add(new DataColumn("Charges", typeof(string))); dtBalancesTable.Columns.Add(new DataColumn("Adjustments", typeof(string))); dtBalancesTable.Columns.Add(new DataColumn("Revenue", typeof(string))); dtBalancesTable.Columns.Add(new DataColumn("Balance", typeof(string))); DataRow drWorkingRow = null; int ColumnIndex = -1; try { System.Collections.Hashtable htAllProvs_Indexes = new System.Collections.Hashtable(); for (int i = 0; i < alProvs.Count; i++) // For Each Provider add a Row in the Balances Table { dtBalancesTable.Rows.Add(dtBalancesTable.NewRow()); dtBalancesTable.Rows[i][0] = alProvs[i].ToString(); } for (int i = 0; i < dtProviderBalance.Rows.Count; i++) { drWorkingRow = dtBalancesTable.Rows[alProvs.IndexOf(dtProviderBalance.Rows[i][0].ToString())]; drWorkingRow[0] = htAllProvs[dtProviderBalance.Rows[i][0].ToString()].ToString(); // the abbreviation // Which Column of the Row to add the number to? Find the column // stated in the query's column 2 string ColumnName_FromQuery = dtProviderBalance.Rows[i][2].ToString(); ColumnIndex = dtBalancesTable.Columns.IndexOf(ColumnName_FromQuery); if (ColumnIndex > 0) drWorkingRow[ColumnIndex] = dtProviderBalance.Rows[i][1].ToString(); // note is not cast as number so numeric specifies cannot apply //ToString("F2"); else drWorkingRow[4] = "ERROR!"; ColumnIndex = -1; } decimal[] Totals = new decimal[4]; // Fill in Null and Empty Entries for (int j = 0; j < dtBalancesTable.Rows.Count; j++) for (int k = 1; k < dtBalancesTable.Columns.Count; k++) { if (dtBalancesTable.Rows[j][k] == null || dtBalancesTable.Rows[j][k].ToString().Trim() == "") dtBalancesTable.Rows[j][k] = "0.00"; if (k == dtBalancesTable.Columns.Count - 1) { decimal Balance = decimal.Parse(dtBalancesTable.Rows[j][1].ToString()) + decimal.Parse(dtBalancesTable.Rows[j][2].ToString()) + decimal.Parse(dtBalancesTable.Rows[j][3].ToString()); dtBalancesTable.Rows[j][4] = Balance.ToString("F2"); } // Add to the Totals to be placed at the bottom of the Table Totals[k - 1] += decimal.Parse(dtBalancesTable.Rows[j][k].ToString()); // Format the Numbers Better dtBalancesTable.Rows[j][k] = decimal.Parse(dtBalancesTable.Rows[j][k].ToString()).ToString("F2"); } DataRow TotalRow = dtBalancesTable.NewRow(); TotalRow[0] = "Totals-->"; for (int i = 1; i < dtBalancesTable.Columns.Count; i++) TotalRow[i] = Totals[i - 1].ToString("F2"); dtBalancesTable.Rows.Add(TotalRow); } catch { } rValReturnTable = dtBalancesTable; // Set this first becuase SummaryTable_as_Strings() will check for _SummaryTable != null // _SummaryTableHeader = SummaryTable_as_Strings(); } return rValReturnTable; }
public static CashBackEntity ExportBalanceRoomHistory(CashBackEntity cashBackEntity) { OracleParameter[] parm ={ new OracleParameter("HOTELID",OracleType.VarChar), new OracleParameter("ROOMCD",OracleType.VarChar), new OracleParameter("STARTDT",OracleType.VarChar), new OracleParameter("ENDDT",OracleType.VarChar) }; CashBackDBEntity dbParm = (cashBackEntity.CashBackDBEntity.Count > 0) ? cashBackEntity.CashBackDBEntity[0] : new CashBackDBEntity(); parm[0].Value = dbParm.HotelID; if (String.IsNullOrEmpty(dbParm.HRoomList)) { parm[1].Value = DBNull.Value; } else { parm[1].Value = dbParm.HRoomList; } if (String.IsNullOrEmpty(dbParm.InDateFrom)) { parm[2].Value = DBNull.Value; } else { parm[2].Value = dbParm.InDateFrom; } if (String.IsNullOrEmpty(dbParm.InDateTo)) { parm[3].Value = DBNull.Value; } else { parm[3].Value = dbParm.InDateTo; } DataSet dsResult = new DataSet(); DataSet dsRoomList = HotelVp.Common.DBUtility.DbManager.Query("CashBack", "t_lm_b_balancerom_roomlist", true, parm); DataSet dsDataList = HotelVp.Common.DBUtility.DbManager.Query("CashBack", "t_lm_b_balancerom_select", true, parm); System.Collections.Hashtable htRoomNm = new System.Collections.Hashtable(); dsResult.Tables.Add(new DataTable()); dsResult.Tables[0].Columns.Add("EFFECTDT"); foreach (DataRow drCol in dsRoomList.Tables[0].Rows) { dsResult.Tables[0].Columns.Add(drCol["rate_code"].ToString().ToUpper() + "-" + drCol["room_type_code"].ToString().ToUpper()); if (!htRoomNm.ContainsKey(drCol["rate_code"].ToString().ToUpper() + "-" + drCol["room_type_code"].ToString().ToUpper())) { htRoomNm.Add(drCol["rate_code"].ToString().ToUpper() + "-" + drCol["room_type_code"].ToString().ToUpper(), GetColsNameByRoomTypeCode(dbParm.HotelID, drCol["room_type_code"].ToString())); } } string strDate = string.Empty; foreach (DataRow drVal in dsDataList.Tables[0].Rows) { if (!strDate.Equals(drVal["EFFECTDATE"].ToString())) { strDate = drVal["EFFECTDATE"].ToString(); DataRow[] drList = dsDataList.Tables[0].Select("EFFECTDATE='" + strDate + "'"); if (drList.Count() == 0) { continue; } DataRow drRow = dsResult.Tables[0].NewRow(); drRow["EFFECTDT"] = strDate; string strColNM = string.Empty; foreach (DataRow drTemp in drList) { strColNM = drTemp["rate_code"].ToString().ToUpper() + "-" + drTemp["room_type_code"].ToString().ToUpper(); drRow[strColNM] = ("42".Equals(drTemp["commision_mode"].ToString())) ? drTemp["commision"].ToString() + "%" : drTemp["commision"].ToString() + "元"; } dsResult.Tables[0].Rows.Add(drRow); } } dsResult.Tables[0].Columns["EFFECTDT"].ColumnName = "日期/房型"; for (int i = 1; i < dsResult.Tables[0].Columns.Count; i++) { dsResult.Tables[0].Columns[i].ColumnName = dsResult.Tables[0].Columns[i].ColumnName.Substring(0, dsResult.Tables[0].Columns[i].ColumnName.IndexOf('-') + 1) + htRoomNm[dsResult.Tables[0].Columns[i].ColumnName].ToString(); } cashBackEntity.QueryResult = dsResult; return cashBackEntity; }
/// <summary> /// This expects that the last column will be Amount. If not It will do nothing. /// RunDetialReport(Guarantor) query first. // Adds Provider's abbreviations to Table as well /// /// Adds a column to report.TableQ /// </summary> private static void AddColBalance(ReportSimpleGrid report) //to report.TableQ { if (report.TableQ != null && report.TableQ.Columns.Count == 10) if (report.TableQ.Columns[8].ColumnName == "Amount") { decimal RunningBalance = 0; // Find Provider Abbreviations System.Collections.Hashtable htProvs = new System.Collections.Hashtable(); try { DataTable dt = Db.GetTableOld("SELECT ProvNum, Abbr FROM Provider"); if (dt.Rows.Count != 0) foreach (DataRow dr in dt.Rows) if (!htProvs.ContainsKey(dr[0].ToString())) htProvs[dr[0].ToString()] = dr[1].ToString(); if (!htProvs.ContainsKey("0")) htProvs["0"] = "UnEarned"; } catch { } for (int i = 0; i < report.TableQ.Rows.Count; i++) { try { decimal amount = 0; try { amount = decimal.Parse(report.TableQ.Rows[i][8].ToString()); } catch { } RunningBalance += amount; if (amount > 0) { report.TableQ.Rows[i][5] = amount.ToString("F2"); report.TableQ.Rows[i][6] = ""; } else { report.TableQ.Rows[i][5] = ""; report.TableQ.Rows[i][6] = amount.ToString("F2"); } report.TableQ.Rows[i][7] = RunningBalance.ToString("F2"); // Fix Provider Column From # to Abreviation, Need to do it here // because Prov# = 0 is undefined if (htProvs.Count != 0) if (htProvs.ContainsKey(report.TableQ.Rows[i][9].ToString())) report.TableQ.Rows[i][4] = htProvs[report.TableQ.Rows[i][9].ToString()].ToString(); // Change Column 0 Date Display if Date on previous row has been displayed if (i > 0) if (report.TableQ.Rows[i][0].ToString() == report.TableQ.Rows[i - 1][0].ToString()) report.TableQ.Rows[i][0] = ""; // makes Dates more readable if not redundant. } catch { report.TableQ.Rows[i][7] = "ERROR"; } } report.TableQ.Columns.RemoveAt(8);// Remove Amount report.TableQ.Columns.RemoveAt(8); // Remove ProvNums DataRow dr2 = report.TableQ.NewRow(); report.TableQ.Rows.Add(dr2); // add blank row dr2 = report.TableQ.NewRow(); dr2[6] = "Total"; dr2[7] = RunningBalance.ToString("F"); report.TableQ.Rows.Add(dr2); } }
private void RecalculateParameterSet() { // save old values System.Collections.Hashtable byName = new System.Collections.Hashtable(); for(int i=0;i<_currentParameters.Count;i++) byName.Add(_currentParameters[i].Name,_currentParameters[i]); // now restore the values _currentParameters.Clear(); for(int i=0;i<_fitEnsemble.NumberOfParameters;i++) { string name = _fitEnsemble.ParameterName(i); if(byName.ContainsKey(name)) _currentParameters.Add((ParameterSetElement)byName[name]); else _currentParameters.Add(new ParameterSetElement(name)); } _currentParameters.OnInitializationFinished(); }
// Static void method with same signature as "Main" is always // file base name: // /// <summary> /// VTK test Main method /// </summary> public static void vtkObjectTest(string[] args) { // Reference a method in the Kitware.VTK assembly: // (forces the Kitware.VTK assembly to load...) // string version = Kitware.VTK.vtkVersion.GetVTKSourceVersion(); string assemblyname = "Kitware.VTK"; bool listAllAssemblies = false; bool listAllClasses = false; bool collectingClassNames = false; System.Collections.Hashtable classnames = new System.Collections.Hashtable(); System.Collections.Hashtable classtypes = new System.Collections.Hashtable(); for (int i = 0; i < args.Length; ++i) { string s = args[i]; if (s == "--assemblyname") { collectingClassNames = false; if (i < args.Length - 1) { assemblyname = args[i + 1]; } else { throw new System.Exception("--assemblyname used, but no name given"); } } else if (s == "--classname") { collectingClassNames = false; if (i < args.Length - 1) { classnames.Add(args[i + 1], args[i + 1]); } else { throw new System.Exception("--classname used, but no name given"); } } else if (s == "--classnames") { collectingClassNames = true; } else if (s == "--classnames-file") { if (i < args.Length - 1) { ReadClassNamesFromFile(classnames, args[i + 1]); } else { throw new System.Exception("--classnames-file used, but no filename given"); } } else if (s == "--list-all-classes") { collectingClassNames = false; listAllClasses = true; } else if (s == "--list-all-assemblies") { collectingClassNames = false; listAllAssemblies = true; } else if (collectingClassNames) { classnames.Add(s, s); } } if (0 == classnames.Count) { classnames.Add("vtkObject", "vtkObject"); } // Find the assembly containing the class to instantiate: // System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); System.Reflection.Assembly assembly = null; foreach (System.Reflection.Assembly a in assemblies) { System.Reflection.AssemblyName aname = a.GetName(); if (aname.FullName == assemblyname || aname.Name == assemblyname) { assembly = a; } if (listAllAssemblies) { //System.Console.Error.WriteLine(aname.Name); System.Console.Error.WriteLine(aname.FullName); } } if (listAllAssemblies) { return; } // Find the type of the class to instantiate: // if (assembly != null) { foreach (System.Type et in assembly.GetExportedTypes()) { if (listAllClasses) { System.Console.Error.WriteLine(et.Name); System.Console.Error.WriteLine(et.AssemblyQualifiedName); } if (classnames.ContainsKey(et.Name)) { classtypes.Add(et.Name, et); } if (classnames.ContainsKey(et.AssemblyQualifiedName)) { classtypes.Add(et.AssemblyQualifiedName, et); } } if (listAllClasses) { return; } } if (0 == classtypes.Count) { throw new System.ArgumentException(System.String.Format( "error: did not find any Type objects... Typo in command line args?")); } // Instantiate and print each type: // string classname = ""; System.Type classtype = null; System.Console.Error.WriteLine(""); System.Console.Error.WriteLine("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)"); System.Console.Error.WriteLine(""); System.Console.Error.WriteLine(System.String.Format("classtypes.Count: {0}", classtypes.Count)); System.Console.Error.WriteLine(""); System.Console.Error.WriteLine(System.String.Format("GetVTKSourceVersion(): '{0}'", version)); System.Console.Error.WriteLine(""); foreach (System.Collections.DictionaryEntry entry in classtypes) { classname = (string) entry.Key; classtype = (System.Type) entry.Value; // Instantiate via "New" method: // System.Console.Error.WriteLine(""); System.Console.Error.WriteLine( "=============================================================================="); System.Console.Error.WriteLine(System.String.Format( "Instantiating and printing class '{0}'", classname)); System.Console.Error.WriteLine(""); // Look for a New method that takes no parameters: // System.Reflection.MethodInfo mi = classtype.GetMethod("New", System.Type.EmptyTypes); if (null == mi) { if (classtype.IsAbstract) { System.Console.Error.WriteLine(System.String.Format( "No 'New' method in abstract class '{0}'. Test passes without instantiating or printing an object.", classname)); } else { System.Console.Error.WriteLine(System.String.Format( "No 'New' method in concrete class '{0}'. Test passes without instantiating or printing an object.", classname)); //throw new System.ArgumentException(System.String.Format( // "error: could not find 'New' method for concrete class '{0}'", // classname)); } } if (null != mi) { // Assumption: any object we create via a 'New' method will implement // the 'IDisposable' interface... // // 'using' forces an 'o.Dispose' call at the closing curly brace: // using (System.IDisposable o = (System.IDisposable) mi.Invoke(null, null)) { System.Console.Error.WriteLine(o.ToString()); } } System.Console.Error.WriteLine(""); // Instantiate via public default constructor: // //System.Type [] ca = new System.Type[0]; //System.Reflection.ConstructorInfo ci = classtype.GetConstructor(ca); //if (null == ci) // { // throw new System.ArgumentException(System.String.Format( // "error: could not find public default constructor for '{0}'", // classname)); // } // //o = ci.Invoke(null); //System.Console.Error.WriteLine(o.ToString()); } }
object dbCmd_GetReaderData(DataType type, object reader) { if (type == DataType.SysAlarmLog) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; try { int GpsX =0, GpsY=0; try { if ((int)dr[2] == 49) { getInterchangePoint((string)dr[9], ((string)dr[10])[0].ToString(), (int)dr[7], ref GpsX, ref GpsY); } else { GetNearDevice((string)dr[9], (int)dr[7], ref GpsX, ref GpsY); } } catch { ; } InsertCommand cmd = GetInsertCmd.setIIPEventCmd(dr,GpsX,GpsY); dbCmd.insert(cmd); //ServerMeg.setServerMeg("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent"); //if (InsertEvent != null) //{ // InsertEvent(cmd.RspID); //} } catch (System.Exception ex) { //���X�ҥ~�|�ɭP�Ѯv�}���ɱҰ�CMS�����p�e���~ //ServerMeg.setAlarmMeg("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent���~!!"); //throw new Exception("�[�J�@���۰ʩΥb�۰ʨƥ��tblIIPEvent���~!!" + "EventID=" + dr[18].ToString() + ",alarmclass" + dr[2].ToString() // + "\r\n" + ex.Message); } } else if (type == DataType.IIPEvent) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; //if (InsertEvent != null) //{ // InsertEvent(dr[0].ToString()); //} } else if (type == DataType.EventID) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; return dr[0]; } else if (type == DataType.Renew) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; System.Collections.Hashtable ht = new System.Collections.Hashtable(); for (int i = 0; i < dr.FieldCount; i++) { if (!ht.ContainsKey(dr.GetName(i))) ht.Add(dr.GetName(i), dr[i]); } return ht; } else if (type == DataType.AllMoveEvent) { System.Data.Odbc.OdbcDataReader dr = (System.Data.Odbc.OdbcDataReader)reader; return new MoveData(Convert.ToInt32(dr[39]), dr[16].ToString(), DateTime.Parse(dr[13].ToString()), dr[6].ToString(), dr[7].ToString(), Convert.ToInt32(dr[10]), Convert.ToInt32(dr[11]), dr[25].ToString()); } return null; }
protected void Page_Load(object sender, EventArgs e) { if (Session["userID"] == null) { // Redirect user to login before doing anything else Response.Redirect("~/Login.aspx?redirect=Orders.aspx"); } else if (Session["userID"] != null && Session["userRole"].Equals("1")) { // Redirect user to login before doing anything else Response.Redirect("~/Home.aspx"); } // Connection setup String myConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; SqlConnection myConnection = new SqlConnection(myConnectionString); // Try to connect try { String criteria = Request.QueryString["criteria"]; DataTable Table1 = new DataTable("MyOrders"); DataRow Row1 = Table1.NewRow(); SqlCommand cmd = new SqlCommand(); cmd.Connection = myConnection; if (criteria == null) { cmd = new SqlCommand("select * from vw_CustomerOrders", myConnection); // Define SQL query } else { cmd = new SqlCommand("select * from vw_CustomerOrders where OrderID='" + criteria + "' or EmailID='" + criteria + "'", myConnection); // Define SQL query } myConnection.Open(); SqlDataReader dr = cmd.ExecuteReader(); // Perform SQL query and store it // Add colums for each field into the table // EmailID, ProductID, Name, Price, SalePrice, InSale, ImageID, ImageData DataColumn oid = new DataColumn("Order ID"); DataColumn emailId = new DataColumn("Email ID"); DataColumn status = new DataColumn("Status"); DataColumn purchaseDate = new DataColumn("Purchase Date"); DataColumn products = new DataColumn("Products"); DataColumn total = new DataColumn("Total"); DataColumn tracking = new DataColumn("Tracking #"); DataColumn actions = new DataColumn("#"); oid.DataType = System.Type.GetType("System.String"); emailId.DataType = System.Type.GetType("System.String"); status.DataType = System.Type.GetType("System.String"); purchaseDate.DataType = System.Type.GetType("System.String"); products.DataType = System.Type.GetType("System.String"); total.DataType = System.Type.GetType("System.String"); tracking.DataType = System.Type.GetType("System.String"); actions.DataType = System.Type.GetType("System.String"); Table1.Columns.Add(oid); Table1.Columns.Add(emailId); Table1.Columns.Add(status); Table1.Columns.Add(purchaseDate); Table1.Columns.Add(products); Table1.Columns.Add(total); Table1.Columns.Add(tracking); Table1.Columns.Add(actions); int orderId = -1; System.Collections.Hashtable orders = new System.Collections.Hashtable(); Double orderTotal = 0.00; while (dr.Read()) { orderId = int.Parse(dr["OrderID"].ToString()); // Add row when a new order is encountered if (!orders.ContainsKey(orderId)) { orders[orderId] += dr["Quantity"].ToString() + "x " + dr["Name"].ToString() + ". "; Row1 = Table1.NewRow(); Table1.Rows.Add(Row1); // Insert values into the row from the query Row1["Order ID"] = dr["OrderID"]; Row1["Email ID"] = dr["EmailID"]; Row1["Status"] = dr["Status"]; Row1["Purchase Date"] = DateTime.Parse(dr["PurchaseDate"].ToString()).ToShortDateString(); Row1["Products"] = orders[orderId]; orderTotal = Double.Parse(dr["OrderTotal"].ToString()) + Double.Parse(dr["TaxAmount"].ToString()) + Double.Parse(dr["ShipAmount"].ToString()); Row1["Total"] = string.Format("{0:$#,###.##}", orderTotal); Row1["Tracking #"] = dr["TrackingID"]; // Columns to purchase item Row1["#"] = ""; // For cancel order } else { orders[orderId] += dr["Quantity"].ToString() + "x " + dr["Name"].ToString() + ". "; Row1["Products"] = orders[orderId]; } } // Add last order dr.Close(); GridView1.DataSource = Table1; GridView1.DataBind(); } catch (SqlException ex) { Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + ex.Message + "')</SCRIPT>"); } finally { myConnection.Close(); } }
internal static System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldNames, IndexReader[] subReaders) { // maintain a unique set of field names System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < subReaders.Length; i++) { IndexReader reader = subReaders[i]; System.Collections.IEnumerator names = reader.GetFieldNames(fieldNames).GetEnumerator(); while (names.MoveNext()) { if (!fieldSet.ContainsKey(names.Current)) fieldSet.Add(names.Current, names.Current); } } return fieldSet.Keys; }
public override System.Collections.ICollection GetIndexedFieldNames(Field.TermVector tvSpec) { System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < readers.Count; i++) { IndexReader reader = ((IndexReader) readers[i]); System.Collections.ICollection names = reader.GetIndexedFieldNames(tvSpec); for (System.Collections.IEnumerator iterator = names.GetEnumerator(); iterator.MoveNext(); ) { System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iterator.Current; System.String s = fi.Key.ToString(); if (fieldSet.ContainsKey(s) == false) { fieldSet.Add(s, s); } } } return fieldSet; }
/// <summary> Walk the file list looking for name collisions. /// If we find one, then we remove it /// </summary> internal virtual System.Collections.ArrayList trimFileList(System.Collections.ArrayList files) { System.Collections.Hashtable names = new System.Collections.Hashtable(); System.Collections.ArrayList list = new System.Collections.ArrayList(); int size = files.Count; for (int i = 0; i < size; i++) { bool addIt = false; SourceFile fi = (SourceFile) files[i]; // no filter currently in place so we add the file as long // as no duplicates exist. We use the original Swd full // name for matching. String fName = fi.RawName; if (m_swfFilter == null) { // If it exists, then we don't add it! if (!names.ContainsKey(fName)) addIt = true; } else { // we have a filter in place so, see // if the source file is in our currently // selected swf. addIt = m_swfFilter.containsSource(fi); } // did we mark this one to add? if (addIt) { names[fName] = fName; list.Add(fi); } } return list; }
/// <seealso cref="IndexReader#GetFieldNames(IndexReader.FieldOption)"> /// </seealso> public override System.Collections.ICollection GetFieldNames(IndexReader.FieldOption fieldNames) { // maintain a unique set of field names System.Collections.Hashtable fieldSet = new System.Collections.Hashtable(); for (int i = 0; i < subReaders.Length; i++) { IndexReader reader = subReaders[i]; System.Collections.ICollection names = reader.GetFieldNames(fieldNames); for (System.Collections.IEnumerator iterator = names.GetEnumerator(); iterator.MoveNext(); ) { System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) iterator.Current; System.String s = fi.Key.ToString(); if (fieldSet.ContainsKey(s) == false) { fieldSet.Add(s, s); } } } return fieldSet; }
private static void updateMs(StringBuilder str, Assembly assembly, Type baseEntityType) { foreach (Type entityType in assembly.GetTypes()) { bool Table = true; if (entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), false).Length > 0) { object obje = (EntityDefinitionAttribute)entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), false)[0]; Table = ((EntityDefinitionAttribute)obje).IsTable; } if (!entityType.IsClass || !entityType.IsSubclassOf(baseEntityType) || entityType.IsGenericType || entityType.Name.Contains("<") || !Table) continue; PropertyInfo[] props = PersistenceStrategyProvider.FindStrategyFor(entityType) .GetPersistentProperties(entityType); object[] memberinfo = entityType.GetCustomAttributes(typeof(EntityDefinitionAttribute), true); string className = entityType.Name; if (Configuration.GetValue("DbType")!= "System.Data.Sqlite"&&TableExistMs(className)) { DataTable table = executeSql("select * from " + className + " where Id=-1"); System.Collections.Hashtable fieldDictionary = new System.Collections.Hashtable(); foreach (PropertyInfo property in props) { //Derviş Aygün FieldDefinitionAttribute fielddefinition = ReflectionHelper.GetAttribute<FieldDefinitionAttribute>(property); if (fielddefinition != null && fielddefinition.MappingType == FieldMappingType.No) continue; //Derviş Aygün FieldDefinitionAttribute definition = DataDictionary.Instance.GetFieldDefinition(className + "." + property.Name); string fieldname = (property.PropertyType.IsSubclassOf(baseEntityType)) ? definition.Name + "_Id" : definition.Name; fieldDictionary[fieldname] = 1; if (!table.Columns.Contains(fieldname)) { string sql = "alter table " + className + " add " + fieldname + " " + MapType(definition); executeNonQuery(sql); str.Append("New Field: " + fieldname + ", Table: " + className + "<br/>"); } else if (!fieldname.EndsWith("_Id") && table.Columns[fieldname].DataType.Name != definition.TypeName) { string sql = "alter table " + className + " alter column " + fieldname + " " + MapType(definition); executeNonQuery(sql); str.Append("Alter Field: " + fieldname + ", Table: " + className + "<br/>"); } } foreach (DataColumn column in table.Columns) { if (!fieldDictionary.ContainsKey(column.ColumnName)) { string sql = "alter table " + className + " drop column " + column.ColumnName; executeNonQuery(sql); str.Append("Drop Field: " + column.ColumnName + ", Table: " + className + "<br/>"); } } } else { //Hiç özelliği olmayan class lar olabilir if (props.Length == 0) { continue; } StringBuilder s = new System.Text.StringBuilder(); s.Append("CREATE TABLE " + className + " ("); foreach (PropertyInfo property in props) { FieldDefinitionAttribute definition = DataDictionary.Instance.GetFieldDefinition(className + "." + property.Name); string fieldname = (property.PropertyType.IsSubclassOf(baseEntityType)) ? definition.Name + "_Id" : definition.Name; s.Append(fieldname + " " + MapType(definition)); if (definition.Name == "Id") { if (memberinfo != null && memberinfo.Length > 0) { EntityDefinitionAttribute attirebute = (EntityDefinitionAttribute)memberinfo[0]; if (attirebute.IdMethod == IdMethod.UserSubmitted) if (Configuration.GetValue("DbType")!= "System.Data.Sqlite") s.Append(" CONSTRAINT PK_" + className + "_Id PRIMARY KEY CLUSTERED"); else s.Append(" PRIMARY KEY"); } else s.Append(" IDENTITY(1,1) CONSTRAINT PK_" + className + "_Id PRIMARY KEY CLUSTERED"); } s.Append(", "); } s.Remove(s.Length - 2, 2); s.Append(")"); string sql = s.ToString(); executeNonQuery(sql); str.Append("New Table: " + className + "<br/>"); } System.Collections.Hashtable fields = new System.Collections.Hashtable(); Dictionary<string, List<string>> uniqueGroup = new Dictionary<string, List<string>>(); Dictionary<string, List<string>> nonUniqueGroup = new Dictionary<string, List<string>>(); foreach (PropertyInfo property in props) { FieldDefinitionAttribute definition = DataDictionary.Instance.GetFieldDefinition(className + "." + property.Name); string fieldname = (property.PropertyType.IsSubclassOf(baseEntityType)) ? definition.Name + "_Id" : definition.Name; if (!string.IsNullOrEmpty(definition.UniqueIndexGroup)) { if (!uniqueGroup.ContainsKey(definition.UniqueIndexGroup)) uniqueGroup[definition.UniqueIndexGroup] = new List<string>(); uniqueGroup[definition.UniqueIndexGroup].Add(fieldname); } if (!string.IsNullOrEmpty(definition.NonUniqueIndexGroup)) { if (!nonUniqueGroup.ContainsKey(definition.NonUniqueIndexGroup)) nonUniqueGroup[definition.NonUniqueIndexGroup] = new List<string>(); nonUniqueGroup[definition.NonUniqueIndexGroup].Add(fieldname); } } foreach (string indexGroup in uniqueGroup.Keys) { executeNonQuery(CreateIndex(className, true, indexGroup, uniqueGroup[indexGroup])); } foreach (string indexGroup in nonUniqueGroup.Keys) { executeNonQuery(CreateIndex(className, false, indexGroup, nonUniqueGroup[indexGroup])); } } }
/// <summary> /// Emulates the behavior of a SAX parser, it realizes the callback events of the parser. /// </summary> private void DoParsing() { System.Collections.Hashtable prefixes = new System.Collections.Hashtable(); System.Collections.Stack stackNameSpace = new System.Collections.Stack(); locator = new XmlSaxLocatorImpl(); try { UpdateLocatorData(this.locator, (System.Xml.XmlTextReader)(this.reader)); if (this.callBackHandler != null) this.callBackHandler.setDocumentLocator(locator); if (this.callBackHandler != null) this.callBackHandler.startDocument(); while (this.reader.Read()) { UpdateLocatorData(this.locator, (System.Xml.XmlTextReader)(this.reader)); switch (this.reader.NodeType) { case System.Xml.XmlNodeType.Element: bool Empty = reader.IsEmptyElement; System.String namespaceURI = ""; System.String localName = ""; if (this.namespaceAllowed) { namespaceURI = reader.NamespaceURI; localName = reader.LocalName; } System.String name = reader.Name; SaxAttributesSupport attributes = new SaxAttributesSupport(); if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); System.String prefixName = (reader.Name.IndexOf(":") > 0) ? reader.Name.Substring(reader.Name.IndexOf(":") + 1, reader.Name.Length - reader.Name.IndexOf(":") - 1) : ""; System.String prefix = (reader.Name.IndexOf(":") > 0) ? reader.Name.Substring(0, reader.Name.IndexOf(":")) : reader.Name; bool IsXmlns = prefix.ToLower().Equals("xmlns"); if (this.namespaceAllowed) { if (!IsXmlns) attributes.Add(reader.NamespaceURI, reader.LocalName, reader.Name, "" + reader.NodeType, reader.Value); } else attributes.Add("", "", reader.Name, "" + reader.NodeType, reader.Value); if (IsXmlns) { System.String namespaceTemp = ""; namespaceTemp = (namespaceURI.Length == 0) ? reader.Value : namespaceURI; if (this.namespaceAllowed && !prefixes.ContainsKey(namespaceTemp) && namespaceTemp.Length > 0) { stackNameSpace.Push(name); System.Collections.Stack namespaceStack = new System.Collections.Stack(); namespaceStack.Push(prefixName); prefixes.Add(namespaceURI, namespaceStack); if (this.callBackHandler != null) ((IXmlSaxContentHandler)this.callBackHandler).startPrefixMapping(prefixName, namespaceTemp); } else { if (this.namespaceAllowed && namespaceTemp.Length > 0 && !((System.Collections.Stack)prefixes[namespaceTemp]).Contains(reader.Name)) { ((System.Collections.Stack)prefixes[namespaceURI]).Push(prefixName); if (this.callBackHandler != null) ((IXmlSaxContentHandler)this.callBackHandler).startPrefixMapping(prefixName, reader.Value); } } } } } if (this.callBackHandler != null) this.callBackHandler.startElement(namespaceURI, localName, name, attributes); if (Empty) { if (this.NamespaceAllowed) { if (this.callBackHandler != null) this.callBackHandler.endElement(namespaceURI, localName, name); } else if (this.callBackHandler != null) this.callBackHandler.endElement("", "", name); } break; case System.Xml.XmlNodeType.EndElement: if (this.namespaceAllowed) { if (this.callBackHandler != null) this.callBackHandler.endElement(reader.NamespaceURI, reader.LocalName, reader.Name); } else if (this.callBackHandler != null) this.callBackHandler.endElement("", "", reader.Name); if (this.namespaceAllowed && prefixes.ContainsKey(reader.NamespaceURI) && ((System.Collections.Stack)stackNameSpace).Contains(reader.Name)) { stackNameSpace.Pop(); System.Collections.Stack namespaceStack = (System.Collections.Stack)prefixes[reader.NamespaceURI]; while (namespaceStack.Count > 0) { System.String tempString = (System.String)namespaceStack.Pop(); if (this.callBackHandler != null) ((IXmlSaxContentHandler)this.callBackHandler).endPrefixMapping(tempString); } prefixes.Remove(reader.NamespaceURI); } break; case System.Xml.XmlNodeType.Text: if (this.callBackHandler != null) this.callBackHandler.characters(reader.Value.ToCharArray(), 0, reader.Value.Length); break; case System.Xml.XmlNodeType.Whitespace: if (this.callBackHandler != null) this.callBackHandler.ignorableWhitespace(reader.Value.ToCharArray(), 0, reader.Value.Length); break; case System.Xml.XmlNodeType.ProcessingInstruction: if (this.callBackHandler != null) this.callBackHandler.processingInstruction(reader.Name, reader.Value); break; case System.Xml.XmlNodeType.Comment: if (this.lexical != null) this.lexical.comment(reader.Value.ToCharArray(), 0, reader.Value.Length); break; case System.Xml.XmlNodeType.CDATA: if (this.lexical != null) { lexical.startCDATA(); if (this.callBackHandler != null) this.callBackHandler.characters(this.reader.Value.ToCharArray(), 0, this.reader.Value.ToCharArray().Length); lexical.endCDATA(); } break; case System.Xml.XmlNodeType.DocumentType: if (this.lexical != null) { System.String lname = this.reader.Name; System.String systemId = null; if (this.reader.AttributeCount > 0) systemId = this.reader.GetAttribute(0); this.lexical.startDTD(lname, null, systemId); this.lexical.startEntity("[dtd]"); this.lexical.endEntity("[dtd]"); this.lexical.endDTD(); } break; } } if (this.callBackHandler != null) this.callBackHandler.endDocument(); } catch (System.Xml.XmlException e) { throw e; } }
/// <summary>Creates a new instance of ProfileName </summary> /// <param name="profileName">the name of the profile /// </param> /// <param name="profileStructureType">The Profile Structure Type for this Name. The /// Profile Structure Type is prepended to each class in the class hierarchy /// both for clarity and to avoid name collisions. /// </param> /// <param name="nameMap">a list of all the children in ProfileName /// </param> /// <param name="parentName">the name of the parent to the child /// </param> private ProfileName(System.String profileName, int profileStructureType, System.Collections.Hashtable nameMap, System.String parentName) { this.profileName = new System.Text.StringBuilder(profileName).ToString(); this.profileStructureType = profileStructureType; this.nameMap = nameMap; this.parentName = parentName; // TODO: These are workarounds.. These should probably be resolved somehow. if (profileName.Equals("Acknowledgment Code")) this.profileName = "Acknowledgement Code"; if (this.parentName != null && this.parentName.Equals("NK1") && profileName.Equals("Name")) this.profileName = "NKName"; // Append a number to the name if there is already a ProfileName with this particular name int i = 1; while (nameMap.ContainsKey(this.profileStructureType + this.profileName)) { i++; this.profileName = new System.Text.StringBuilder(profileName + i).ToString(); } // Store the new name in the hashmap nameMap[this.profileStructureType + this.profileName] = null; }