Example #1
0
        private void SetIntroText(InstructType mode, bool backAvail)
        {
            string msg   = "";
            Color  color = Color.White;

            switch (mode)
            {
            case InstructType.BeforePoll:
                msg   = "Private instructions before poll:";
                color = Color.LightSteelBlue;
                menuItemBack.Enabled = false; // This first screen always has the Back button disabled
                break;

            case InstructType.BeginMessage:
                msg   = "Please read the following to the respondent:";
                color = Color.FromArgb(255, 200, 200);
                menuItemBack.Enabled = backAvail;
                break;

            case InstructType.AfterPoll:
                msg   = "Private instructions after poll:";
                color = Color.Thistle;
                menuItemBack.Enabled = backAvail;
                break;

            case InstructType.EndMessage:
                msg   = "Please read the following to the respondent:";
                color = Color.FromArgb(142, 218, 192);
                menuItemBack.Enabled = backAvail;
                break;

            case InstructType.AfterAllPolls:
                msg   = "Private instructions after all respondents:";
                color = Color.FromArgb(255, 189, 123);
                menuItemBack.Enabled = false; // This last screen always has the Back button disabled (this is redundant because backAvail is always false for this screen)
                break;

            default:
                Debug.Fail("Unknown Instructions Type: " + mode.ToString(), "frmInstructions.SetIntroText");
                break;
            }

            labelIntro.Text      = msg;
            this.BackColor       = color;
            labelIntro.BackColor = color;
        }
Example #2
0
        public int ScreenAdv; // -1 : Move backward one screen   +1 : Move forward one screen



        public frmInstructions(string text, InstructType mode, ref int screenAdv, ref bool backAvail)
        {
            Cursor.Current = Cursors.WaitCursor;
            InitializeComponent();
            InitializeScreen();

            SetIntroText(mode, backAvail);
            textBoxMain.Text = text;

            ToolsCF.SipShowIM(0);
            this.BringToFront();
            Cursor.Current = Cursors.Default;
            this.Resize   += new System.EventHandler(this.frmInstructions_Resize);

            this.ShowDialog();

            screenAdv = ScreenAdv;
            backAvail = true; // Setting this to true will make this just displayed screen the "back one"

            this.Resize -= new System.EventHandler(this.frmInstructions_Resize);
        }
Example #3
0
        public void CreateInstruct(int userID, InstructType type, object datas, bool isSync)
        {
            ///检查是否开放Passport服务器
            if (!AllSettings.Current.PassportServerSettings.EnablePassportService)
            {
                return;
            }

            Instruct ins = new Instruct();

            string tempData = string.Empty;

            if (Serializer.IsSimpleDataTypes(datas))
            {
                tempData = datas.ToString();
            }
            else
            {
                tempData = Serializer.GetXML(datas);
            }

            ins.Datas        = tempData;
            ins.InstructType = type;
            ins.TargetID     = userID;
            ins.IsSync       = isSync;

            InstructDriver driver;

            foreach (KeyValuePair <int, InstructDriver> item in this.DriverList)
            {
                driver = item.Value;
                if (driver.Client.InstructTypes.Count == 0 || driver.Client.InstructTypes.Contains(type))
                {
                    driver.AppendInstruct(ins);
                }
            }
        }
Example #4
0
 public void CreateInstruct(int userID, InstructType type, object datas)
 {
     CreateInstruct(userID, type, datas, false);
 }
Example #5
0
        public void CreateInstruct(int userID, InstructType type, object datas, bool isSync)
        {
            ///检查是否开放Passport服务器
            if (!AllSettings.Current.PassportServerSettings.EnablePassportService)
                return;

            Instruct ins = new Instruct();

            string tempData = string.Empty;

            if (Serializer.IsSimpleDataTypes(datas))
                tempData = datas.ToString();
            else
                tempData = Serializer.GetXML(datas);

            ins.Datas = tempData;
            ins.InstructType = type;
            ins.TargetID = userID;
            ins.IsSync = isSync;

            InstructDriver driver;

            foreach (KeyValuePair<int, InstructDriver> item in this.DriverList)
            {
                driver = item.Value;
                if (driver.Client.InstructTypes.Count == 0 || driver.Client.InstructTypes.Contains(type))
                {
                    driver.AppendInstruct(ins);
                }
            }
        }
Example #6
0
 public void CreateInstruct(int userID, InstructType type, object datas)
 {
     CreateInstruct(userID, type, datas, false);
 }
Example #7
0
        public APIResult Passport_RegiserClient( string ownerUsername,string ownerPassword, string clientName,string url,string apiFilePath,string accessKey,int[] instructList,out int clientID)
        {
            APIResult result = new APIResult();

            string ip = Context.Request.UserHostAddress; //获取客户端ip
            int count=0;
            KeyValuePair<string, int> tryer = new KeyValuePair<string, int>();
            foreach ( KeyValuePair<string,int> c in clientTryRegCounter)
            {
                if (c.Key == ip)
                {
                    tryer = c;
                    break;
                }
            }

            count = tryer.Value;
            

            if (count > 10) //最多一个IP10次尝试
            {
                result.IsSuccess = false;
                result.Messages.Add("超过允许的尝试注册次数!请联系Passport管理员");
                clientID = 0;
                return result;
            }

            if (clientTryRegCounter.Count > 100)  //每次超过100个客户端要注册, 认为是不正常的
            {
                throw new Exception("接口出现异常,已关闭注册。 请联系服务器管理员");
            }

            clientID = 0;
      
            AuthUser user = UserBO.Instance.GetAuthUser(ownerUsername);
            if (user == null
                || user == MaxLabs.bbsMax.Entities.User.Guest
                || !user.IsOwner
                || !SecurityUtil.ComparePassword( user.PasswordFormat, ownerPassword, user.Password))
            {
                result.IsSuccess = false;
                result.Messages .Add( "Passport创始人信息无效!");

                if (string.IsNullOrEmpty(tryer.Key))
                {
                    tryer = new KeyValuePair<string, int>(ip, 1);
                    clientTryRegCounter.Add(tryer);
                }
                else
                {
                    clientTryRegCounter.Remove(tryer);
                    clientTryRegCounter.Add(new KeyValuePair<string, int>(ip, count + 1));
                }

                return result;
            }

            using (ErrorScope es = new ErrorScope())
            {
                InstructType[] instrcuts = new InstructType[instructList == null ? 0 : instructList.Length];

                for (int i = 0; i < instrcuts.Length; i++)
                    instrcuts[i] = (InstructType) instructList[i];

                PassportClient client = PassportBO.Instance.CreatePassportClient(clientName, url, apiFilePath, accessKey, instrcuts);
                if (client == null)
                {
                    result.IsSuccess = false;

                    es.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        result.AddError(error.TatgetName,error.Message);
                    }
                    );
                }
                else
                {
                    clientID = client.ClientID;
                    result.IsSuccess = true;
                }
            }

            return result;
        }
Example #8
0
        public APIResult Passport_RegiserClient(string ownerUsername, string ownerPassword, string clientName, string url, string apiFilePath, string accessKey, int[] instructList, out int clientID)
        {
            APIResult result = new APIResult();

            string ip    = Context.Request.UserHostAddress; //获取客户端ip
            int    count = 0;
            KeyValuePair <string, int> tryer = new KeyValuePair <string, int>();

            foreach (KeyValuePair <string, int> c in clientTryRegCounter)
            {
                if (c.Key == ip)
                {
                    tryer = c;
                    break;
                }
            }

            count = tryer.Value;


            if (count > 10) //最多一个IP10次尝试
            {
                result.IsSuccess = false;
                result.Messages.Add("超过允许的尝试注册次数!请联系Passport管理员");
                clientID = 0;
                return(result);
            }

            if (clientTryRegCounter.Count > 100)  //每次超过100个客户端要注册, 认为是不正常的
            {
                throw new Exception("接口出现异常,已关闭注册。 请联系服务器管理员");
            }

            clientID = 0;

            AuthUser user = UserBO.Instance.GetAuthUser(ownerUsername);

            if (user == null ||
                user == MaxLabs.bbsMax.Entities.User.Guest ||
                !user.IsOwner ||
                !SecurityUtil.ComparePassword(user.PasswordFormat, ownerPassword, user.Password))
            {
                result.IsSuccess = false;
                result.Messages.Add("Passport创始人信息无效!");

                if (string.IsNullOrEmpty(tryer.Key))
                {
                    tryer = new KeyValuePair <string, int>(ip, 1);
                    clientTryRegCounter.Add(tryer);
                }
                else
                {
                    clientTryRegCounter.Remove(tryer);
                    clientTryRegCounter.Add(new KeyValuePair <string, int>(ip, count + 1));
                }

                return(result);
            }

            using (ErrorScope es = new ErrorScope())
            {
                InstructType[] instrcuts = new InstructType[instructList == null ? 0 : instructList.Length];

                for (int i = 0; i < instrcuts.Length; i++)
                {
                    instrcuts[i] = (InstructType)instructList[i];
                }

                PassportClient client = PassportBO.Instance.CreatePassportClient(clientName, url, apiFilePath, accessKey, instrcuts);
                if (client == null)
                {
                    result.IsSuccess = false;

                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        result.AddError(error.TatgetName, error.Message);
                    }
                                              );
                }
                else
                {
                    clientID         = client.ClientID;
                    result.IsSuccess = true;
                }
            }

            return(result);
        }
Example #9
0
 public abstract long  WriteInstruct(int targetID, int clientID, InstructType type, DateTime createDate, string datas);
Example #10
0
 public long WriteInstruct(int clientID, int targetID, DateTime createDate, InstructType type, string datas)
 {
     return(PassportDao.Instance.WriteInstruct(targetID, clientID, type, createDate, datas));
 }