public static bool CompErae() { Erae E = new Erae(); DataTable Dr = PublicFunction.d.GetDataTable("select * from CAS_Erae Except select * from CAS_TempErae"); int count = Dr.Rows.Count; for (int i = 0; i != count; i++) { DataRow Temp = Dr.Rows[i]; string code = Temp["Code"].ToString(); string srlcource = Convert.ToString(Temp["Srl_Course"]); string srlmaster = Temp["Srl_Master"].ToString(); string srlTerm = Temp["Srl_Term"].ToString(); PublicFunction.d.Delete("CAS_Erae", "Code=" + code + " and Srl_Course=" + srlcource + " and Srl_Master=" + srlmaster + " and Srl_Term=" + srlTerm); } return(true); }
public static Dictionary <string, int> GetEraeData(int Srl_Term) { Dictionary <string, int> data = new Dictionary <string, int>(); DataTable dt = Erae.GetEraeOfTerm(Srl_Term); if (dt != null) { foreach (DataRow dr in dt.Rows) { string temp = dr["Srl_Course"].ToString() + "-" + dr["Srl_Master"].ToString() + "-" + dr["Srl_Term"].ToString() + "-" + dr["Code"].ToString(); if (!data.ContainsKey(temp)) { data.Add(temp, Convert.ToInt32(dr["Srl"])); } else if (1 < 1) { ; } } } return(data); }
public static async void ImportEraeData(String term) { Dictionary <string, int> MasretData = PublicFunction.GetMasterData(); Dictionary <string, int> CourseData = PublicFunction.GetCourseData(); Dictionary <string, int> GroupData = PublicFunction.GetGroupData(); Dictionary <string, int> EraeData = PublicFunction.GetEraeData(Convert.ToInt32(Term.GetTermSrl(term))); int srlTerm = Convert.ToInt32(Term.GetTermSrl(term)); if (term != "") { DataTable Dt = Department.GetAllDepartment(); if (Dt != null) { foreach (DataRow dr in Dt.Rows) { string TempDepartment = dr["Code"].ToString(); //string TempDepartment = "30"; string TempTerm = term; var values = new Dictionary <string, string> { { "login", "report" }, { "pass", "RKXMSDrkxmsd123" }, { "sec", "1977AD6355" }, { "pub", ("<Root>" + "<N id=\"4\" F1=\"" + TempTerm + "\" T1=\"\" F2=\"\" T2=\"\" A=\"\" S=\"\" Q=\"\" B=\"\" />" + "<N id=\"12\" F1=\"" + TempDepartment + "\" T1=\"\" F2=\"\" T2=\"\" A=\"\" S=\"\" Q=\"\" B=\"\" /></Root>") }, { "pri", "<Root><N UQID=\"278\" id=\"2\" F=\"0\" T=\"\" /></Root>" }, { "mor", "" }, { "iFID", "1134" } }; var url = string.Format("https://golestan.qiet.ac.ir/GolestanService/gservice.asmx/golInfo?{0}", string.Join("&", values.Select(kvp => string.Format("{0}={1}", kvp.Key, kvp.Value)))); try { string a = await client.GetStringAsync(url); XmlDocument d = new XmlDocument(); d.LoadXml(a); string query = ""; XmlNodeList XN = d.SelectNodes("/Root/p"); foreach (XmlNode x in XN) { try { Erae SD = new Erae(); SD.Group = Convert.ToInt32(x.Attributes["c15"].Value); SD.Srl_Term = srlTerm; SD.IsActive = true; // get master code string srl = x.Attributes["c5"].Value.Trim(); if (srl == "") { continue; } SD.Srl_Master = MasretData[srl]; string temp = x.Attributes["c2"].Value; string Code = temp.Substring(0, temp.IndexOf('-')); SD.Srl_Course = CourseData[temp]; string tempErae = SD.Srl_Course + "-" + SD.Srl_Master + "-" + SD.Srl_Term + "-" + SD.Group; query += " Insert Into CAS_TempErae values(" + SD.Srl_Course + "," + SD.Srl_Master + "," + SD.Srl_Term + "," + SD.Group + ",1)"; if (!EraeData.ContainsKey(tempErae)) { EraeData.Add(tempErae, 0); query += " Insert Into CAS_Erae values(" + SD.Srl_Course + "," + SD.Srl_Master + "," + SD.Srl_Term + "," + SD.Group + ",1)"; } } catch { } } PublicFunction.d.ExecQuery(query); EraeData = PublicFunction.GetEraeData(Convert.ToInt32(Term.GetTermSrl(term))); query = ""; Dictionary <string, int> EraeTimeData = new Dictionary <string, int>(); foreach (XmlNode x in XN) { try { Erae SD = new Erae(); SD.Group = Convert.ToInt32(x.Attributes["c15"].Value); SD.Srl_Term = srlTerm; string srl = x.Attributes["c5"].Value.Trim(); if (srl == "") { continue; } SD.Srl_Master = MasretData[srl]; string temp = x.Attributes["c2"].Value; string Code = temp.Substring(0, temp.IndexOf('-')); SD.Srl_Course = CourseData[temp]; string tempErae = SD.Srl_Course + "-" + SD.Srl_Master + "-" + SD.Srl_Term + "-" + SD.Group; int Srl = EraeData[tempErae]; if (Srl != 0 && !EraeTimeData.ContainsKey(Srl.ToString())) { EraeTimeData.Add(Srl.ToString(), 0); string TempStartTime; string TempEndTime; string TempType; string TempDay; string tempSession = x.Attributes["c6"].Value; string[] session = tempSession.Split('،'); for (int i = 0; i < session.Length; i += 3) { TempType = session[i].Trim(); TempDay = session[i + 1].Trim(); TempStartTime = session[i + 2].Trim().Substring(0, 5); TempEndTime = session[i + 2].Trim().Substring(6); query += " Insert Into CAS_EraeTime values (" + Srl.ToString() + "," + PublicFunction.GetDayNumber(TempDay).ToString() + ",N'" + TempStartTime + "',N'" + TempEndTime + "'," + PublicFunction.GetSessionType(TempType).ToString() + ")"; EraeTime et = new global::EraeTime(); query += Session.InsertSession(Srl, PublicFunction.TermStartDate, PublicFunction.TermEndDate, PublicFunction.GetSessionType(TempType), TempDay, TempStartTime, TempEndTime); } } } catch { } } PublicFunction.d.ExecQuery(query); } catch (Exception ex) { } } } } }