Example #1
0
        static private Result Refresh(EServ.Client client, int userno, int privno, ref DictItem item)
        {
            object[] param = new object[] { item.Id };
            Result   r     = null;

            try
            {
                r = client.Call(userno, FileId, FuncNo, privno, param);
                if (r.ResultNo == 0)
                {
                    DataTable dt1 = r.Data.Tables[0];
                    if (dt1.Rows.Count > 0)
                    {
                        item.Name            = ISM.Lib.Static.ToStr(dt1.Rows[0]["Name"]);
                        item.Description     = ISM.Lib.Static.ToStr(dt1.Rows[0]["Description"]);
                        item.RefreshInterval = ISM.Lib.Static.ToInt(dt1.Rows[0]["RefreshInterval"]);
                        item.Loaded          = DateTime.Now;
                        item.Table           = r.Data.Tables[1];
                    }
                    r.Data  = null;
                    r.Param = null;
                }
            }
            catch (Exception ex)
            {
                r = new Result(9, ex.ToString());
            }

            return(r);
        }
Example #2
0
        public Result GetList(int privcode)
        {
            Result r = null;

            try
            {
                if (client == null)
                {
                    r = new Result(9, "Client object should not be null!");
                }
                r = client.Call(userno, 107, 107101, privcode, null);
            }
            catch (Exception ex)
            {
                r = new Result(9, ex.ToString());
            }
            return(r);
        }
Example #3
0
        private void Login(Hashtable namedate, Hashtable dochash, Hashtable rephash, Hashtable slipshash)
        {
            try
            {
                FileStream fs = null;
                moConnection.WaitTimeout = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "TimeOut", 1));
                string   serverip  = Static.ToStr(Static.RegisterGet(mstrRegPath, "Login", "Server", ""));
                int      portno    = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "PortNo", ""));
                int      userno    = Static.ToInt(Static.RegisterGet(mstrRegPath, "Login", "UserNo", ""));
                string[] tfilename = Directory.GetDirectories(Terminaldir);
                if (serverip != "" || portno != 0)
                {
                    moConnection.Connect(serverip, portno);
                    if (moConnection.Connected)
                    {
                        string cas = "";

                        Result res = moConnection.Call(userno, 224, 100003, 100003, new object[] { namedate, dochash, rephash, slipshash });
                        if (res.ResultNo == 0)
                        {
                            Hashtable hash = (Hashtable)res.Param[0];
                            if (hash.Count != 0)
                            {
                                if (!Directory.Exists(@Terminaldir + @"\temp"))
                                {
                                    Directory.CreateDirectory(@Terminaldir + @".\temp");
                                }
                                for (int j = 0; j < hash.Count; j++)
                                {
                                    ArrayList array = (ArrayList)hash[j];
                                    byte[]    bytes = (byte[])array[1];
                                    fs = File.Create(Terminaldir + "\\temp\\" + Static.ToStr(array[0]));
                                    fs.Write(bytes, 0, Static.ToInt(bytes.Length));
                                    fs.Flush();
                                    fs.Close();
                                    fs.Dispose();
                                    cas = cas + SSTCryptographer.Encrypt(Static.ToStr(array[0]), "SampleKey") + " " + array[2] + " " + Static.ToStr(array[3]) + " ";
                                    Program.updatefiles = cas.TrimEnd();
                                    Program.selfupdate  = 1;
                                    selfupdate          = true;
                                }
                            }
                        }
                        else
                        {
                            if (res.ResultNo == 9110135)
                            {
                                Program.updatefiles = res.ResultDesc;
                                string[]  name = res.ResultDesc.Split(' ');
                                Hashtable hash = (Hashtable)res.Param[0];
                                if (hash.Count != 0)
                                {
                                    if (!Directory.Exists(@".\temp"))
                                    {
                                        Directory.CreateDirectory(@".\temp");
                                    }
                                    for (int j = 0; j < hash.Count; j++)
                                    {
                                        ArrayList array = (ArrayList)hash[j];
                                        byte[]    bytes = (byte[])array[1];
                                        fs = File.Create(Terminaldir + "\\temp\\" + Static.ToStr(array[0]));
                                        fs.Write(bytes, 0, Static.ToInt(bytes.Length));
                                        fs.Flush();
                                        fs.Close();
                                        fs.Dispose();
                                        cas = cas + SSTCryptographer.Encrypt(Static.ToStr(array[0]), "SampleKey") + " " + array[2] + " " + Static.ToStr(array[3]) + " ";
                                    }
                                }
                                Program.selfupdate  = 1;
                                Program.updatefiles = cas;
                                MessageBox.Show(this, "Шинэчлэгч өөрийгөө шинэчлэсэн тул хуулах үйлдэл дууссаны дараа дахин шинэчлэх үйлдлээ хийнэ үү.", "Мэдээлэл", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show(res.ResultNo + "  " + res.ResultDesc);
                            }
                        }
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Серверт холбогдож чадсангүй");
                    }
                }
                else
                {
                    MessageBox.Show("Тохиргоо буруу байна.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }