Exemplo n.º 1
0
 /// <summary>
 /// Constructor with passed delegates
 /// </summary>
 /// <param name="_dd">Name of Done Delegate</param>
 /// <param name="_rd">Name of Response Delegate</param>
 public WI(DoneDelegate _dd, ResponseDelegate _rd)
 {
     InitializeComponent();
     ResetAll();
     _doneDelegate = _dd;
     _responseDelegate = _rd;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor with passed response delegate
 /// </summary>
 /// <param name="_rd">Function name of response delegate</param>
 /// <param name="_dd">Function name of done delegate</param>
 public SRT(ResponseDelegate _rd, DoneDelegate _dd)
 {
     InitializeComponent();
     ResetAll();
     _responseDelegate = _rd;
     _doneDelegate = _dd;
 }
Exemplo n.º 3
0
 // Button GoButton)
 public TransactionScript(Source sourceSource, Target targetTarget, Configuration config, DoneDelegate doneHandler)
 {
     this.sourceSource = sourceSource;
     this.targetTarget = targetTarget;
     this.config = config;
     this.doneHandler = doneHandler;
     //this.goButton = GoButton;
 }
Exemplo n.º 4
0
 public void Setup(string message, string taskMessage, string problem, int answer, DoneDelegate onDone)
 {
     this.messageLabel.Text = message;
       this.problemLabel.Text = problem;
       this.problemTextBox.Text = "";
       this.answer = answer;
       this.taskLabel.Text = taskMessage;
       this.doneDelegate = onDone;
 }
Exemplo n.º 5
0
 public void DoneWithUpload()
 {
     if (this.InvokeRequired)
     {
         DoneDelegate del = new DoneDelegate(DoneWithUpload);
         this.Invoke(del, new object[] { });
     }
     else
     {
         progressbar.Value = 0;
         status_display.Text = "Upload Complete, Bridge Submitting File";
         progressbar.Style = ProgressBarStyle.Marquee;
     }
 }
        //===========================[ Add Friends ]=========================//
        public bool AddFriends(DoneDelegate callback, HashSet <long> uids, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("addfriends");

            quest.Param("friends", uids);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
        //===========================[ Add Attributes ]=========================//
        public bool AddAttributes(DoneDelegate callback, Dictionary <string, string> attrs, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("addattrs");

            quest.Param("attrs", attrs);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
        //===========================[ Remove Device ]=========================//
        public bool RemoveDevice(DoneDelegate callback, string deviceToken, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("removedevice");

            quest.Param("devicetoken", deviceToken);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 9
0
        //===========================[ Data Delete ]=========================//
        public bool DataDelete(DoneDelegate callback, string key, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("datadel");

            quest.Param("key", key);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 10
0
        //===========================[ Kickout ]=========================//
        public bool Kickout(DoneDelegate callback, string endpoint, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("kickout");

            quest.Param("ce", endpoint);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 11
0
        internal void StartChecking(string appCast = null, DoneDelegate done = null)
        {
            if (!_initialized)
            {
                done?.Invoke(); return;
            }
            _done = () =>
            {
                Running = false;
                done?.Invoke();
            };
            lock (_initLocker)
            {
                if (Running)
                {
                    Logger.Info(States.StartCheckIgnoredWhileRunning);
                    _done?.Invoke(); return;
                }
                Running = true;
            }

            if (Settings.Mandatory && _remindLaterTimer != null)
            {
                _remindLaterTimer.Stop();
                _remindLaterTimer.Close();
                _remindLaterTimer = null;
            }
            if (_remindLaterTimer != null)
            {
                Logger.Info(States.StartCheckIgnoredForRemindLater);
                _done?.Invoke(); return;
            }

            Logger.Info(States.CheckForUpdateStarted);
            _downloadAndRunWasCall = false;

            if (appCast != null)
            {
                Settings.AppCastURL = appCast;
            }

            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork             += BackgroundWorkerDoWork;
            backgroundWorker.RunWorkerCompleted += BackgroundWorkerOnRunWorkerCompleted;

            backgroundWorker.RunWorkerAsync();
        }
Exemplo n.º 12
0
        //===========================[ Add Debug Log ]=========================//
        public bool AddDebugLog(DoneDelegate callback, string message, string attrs, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("adddebuglog");

            quest.Param("msg", message);
            quest.Param("attrs", attrs);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 13
0
        //===========================[ Add Group Members ]=========================//
        public bool AddGroupMembers(DoneDelegate callback, long groupId, HashSet <long> uids, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("addgroupmembers");

            quest.Param("gid", groupId);
            quest.Param("uids", uids);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 14
0
    public IEnumerator NextCommands(List <GCommand> commands, DoneDelegate done)
    {
        linesCreated = new List <GameObject>();

        foreach (var command in commands)
        {
            if (command.Type == GCommand.CommandType.AbsolutePositioning)
            {
                movementType = Movement.Absolute;
            }
            else if (command.Type == GCommand.CommandType.RelativePositioning)
            {
                movementType = Movement.Relative;
            }
            else if (command.Type == GCommand.CommandType.Move)
            {
                if (ImmediateMove)
                {
                    MoveHeadImmediate(command, ExtruderWidth, LayerHeight);
                }
                else
                {
                    MoveHead(command, ExtruderWidth, LayerHeight);
                }
            }
            else if (command.Type == GCommand.CommandType.Home)
            {
                if (ImmediateMove)
                {
                    HomeImmediate();
                }
                else
                {
                    Home();
                }
            }
            else
            {
                throw new NotSupportedException("PrintHead does not support GCommand " + command.ToString());
            }

            command.ReleaseCommand();
        }
        yield return(null);

        done(linesCreated);
    }
        //-------------[ Delete Messages ]---------------------//
        //-- xid: peer uid, or groupId, or roomId
        //-- type: 1: p2p, 2: group; 3: room
        public bool DeleteMessage(DoneDelegate callback, long xid, long mid, int type, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("delmsg");

            quest.Param("mid", mid);
            quest.Param("xid", xid);
            quest.Param("type", type);

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 16
0
        //===========================[ Set Room Info ]=========================//
        public bool SetRoomInfo(DoneDelegate callback, long roomId, string publicInfo = null, string privateInfo = null, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
                {
                    ClientEngine.RunTask(() =>
                    {
                        callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
                    });
                }

                return(false);
            }

            Quest quest = new Quest("setroominfo");

            quest.Param("rid", roomId);
            if (publicInfo != null)
            {
                quest.Param("oinfo", publicInfo);
            }
            if (privateInfo != null)
            {
                quest.Param("pinfo", privateInfo);
            }

            bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);

            if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
            {
                ClientEngine.RunTask(() =>
                {
                    callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
                });
            }

            return(asyncStarted);
        }
Exemplo n.º 17
0
        private void doLoadFreqs(object state)
        {
            DoneDelegate done = (DoneDelegate)state;

            using (StreamReader sr = new StreamReader("words_types.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] parts = line.Split(',');
                    if (parts.Length != 4)
                    {
                        continue;
                    }
                    int freq = int.Parse(parts[3].Trim('"'));
                    freqs[parts[1].Trim('"')] = freq;
                    corpusN += freq;
                }
            }
            done();
        }
Exemplo n.º 18
0
        //===========================[ Set User Info ]=========================//
        public bool SetUserInfo(DoneDelegate callback, string publicInfo = null, string privateInfo = null, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                return(false);
            }

            Quest quest = new Quest("setuserinfo");

            if (publicInfo != null)
            {
                quest.Param("oinfo", publicInfo);
            }
            if (privateInfo != null)
            {
                quest.Param("pinfo", privateInfo);
            }

            return(client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout));
        }
Exemplo n.º 19
0
        internal void Classify()
        {
            try
            {
                ClassificationResult result = null;
                string url = PrepareUrl();

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.AutomaticDecompression = DecompressionMethods.GZip;

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            string json = reader.ReadToEnd();
                            result = JsonConvert.DeserializeObject <ClassificationResult>(json);
                        }
                DoneDelegate?.Invoke(result);
            }
            catch (Exception ex)
            {
                ErrorDelegate?.Invoke("Request Error", ex.Message);
            }
        }
Exemplo n.º 20
0
        //-- toId: peer uid, or groupId, or roomId
        //-- type: 1: p2p, 2: group; 3: room
        //-- Obsolete in v.2.2.0, will change public to internal.
        internal bool DeleteMessage(DoneDelegate callback, long fromUid, long toId, long messageId, int type, int timeout = 0)
        {
            TCPClient client = GetCoreClient();

            if (client == null)
            {
                if (RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
                {
                    ClientEngine.RunTask(() =>
                    {
                        callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
                    });
                }

                return(false);
            }

            Quest quest = new Quest("delmsg");

            quest.Param("from", fromUid);
            quest.Param("mid", messageId);
            quest.Param("xid", toId);
            quest.Param("type", type);

            bool asyncStarted = client.SendQuest(quest, (Answer answer, int errorCode) => { callback(errorCode); }, timeout);

            if (!asyncStarted && RTMConfig.triggerCallbackIfAsyncMethodReturnFalse)
            {
                ClientEngine.RunTask(() =>
                {
                    callback(fpnn.ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION);
                });
            }

            return(asyncStarted);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Loads word frequency data.
 /// </summary>
 /// <param name="done"></param>
 public void LoadFreqs(DoneDelegate done)
 {
     ThreadPool.QueueUserWorkItem(doLoadFreqs, done);
 }
Exemplo n.º 22
0
 public void SendFile(string sFile)
 {
     _sFilePath = sFile;
     _doneDelegate = null;
     _progressDelegate = null;
     SendFile();
 }
Exemplo n.º 23
0
 //-------------[ Delete Messages ]---------------------//
 public bool DeleteMessage(DoneDelegate callback, long fromUid, long toId, long messageId, MessageCategory messageCategory, int timeout = 0)
 {
     return(DeleteMessage(callback, fromUid, toId, messageId, (byte)messageCategory, timeout));
 }
Exemplo n.º 24
0
 public void BeginSendFile(string sFileName, string sTargetFolder, string sTargetFileName, DoneDelegate doneDelegate, ProgressDelegate progressDelegate)
 {
     _doneDelegate = doneDelegate;
     _progressDelegate = progressDelegate;
     _sTargetFileName = sTargetFileName;
     _sTargetFolder = sTargetFolder;
     AsyncLog(sFileName);
 }
Exemplo n.º 25
0
 // close the application without prompting the user
 private void forceClose()
 {
     if (this.InvokeRequired)
     {
         DoneDelegate d = new DoneDelegate(forceClose);
         this.Invoke(d);
     }
     else
     {
         shouldForceClose = true;
         Close();
         Application.Exit();
     }
 }
Exemplo n.º 26
0
 public Worker(DoneDelegate doneArg)
 {
     Done = doneArg;
 }
Exemplo n.º 27
0
 public void SetAssetLuaFunc(UpdateDelegate update, DoneDelegate done)
 {
     _onUpdate = update;
     _onDone   = done;
 }
Exemplo n.º 28
0
 /// <summary>
 ///     Start checking for new version of application and display dialog to the user if update is available.
 /// </summary>
 /// <param name="appCast">URL of the xml file that contains information about latest version of the application.</param>
 /// <param name="done">Call when it is done.</param>
 public static void Start(string appCast, DoneDelegate done = null)
 {
     Current.StartChecking(appCast, done);
 }
Exemplo n.º 29
0
		/// <summary>
		/// Set things in motion so your service can do its work.
		/// </summary>
		protected override void OnStart(string[] args) {
			ChannelServices.RegisterChannel(new TcpServerChannel("HLRChannel", 65122));
			RemotingConfiguration.RegisterWellKnownServiceType(typeof(HLRLib.HLR), "HelloHLR", WellKnownObjectMode.Singleton);
			
			ChannelServices.RegisterChannel(new TcpServerChannel("WTSChannel", 65123));
			RemotingConfiguration.RegisterWellKnownServiceType(typeof(WTSLib.WTS), "HelloWTS", WellKnownObjectMode.Singleton);

			logHandler = new LogHandler(LogWriter);
			wtsHandler = new WTSHandler(ProcessWTS);
			delegateTicketDone = new DoneDelegate(SetTicketResult);

			strCon = string.Format("application name=TicketProcessor;persist security info=true;packet size=4096;data source={0};initial catalog={1};user id={2};password={3};", ConfigurationSettings.AppSettings["PspServer"], "Psp", ConfigurationSettings.AppSettings["DataUser"], DecryptPassword(ConfigurationSettings.AppSettings["DataPassword"]));
			

			sqlTicket = new SqlCommand("sp_GetTicket");
			sqlTicket.CommandType = CommandType.StoredProcedure;
			sqlTicket.Parameters.Add("@fromdate", SqlDbType.DateTime, 8);
			sqlTicket.CommandTimeout = 60;

			sqlSetResult = new SqlCommand("sp_SetTicketResult");
			sqlSetResult.CommandType = CommandType.StoredProcedure;
			sqlSetResult.Parameters.Add("@tno", SqlDbType.BigInt, 8);
			sqlSetResult.Parameters.Add("@state", SqlDbType.Int, 4);
			sqlSetResult.Parameters.Add("@trycount", SqlDbType.Int, 4);
			sqlSetResult.Parameters.Add("@result", SqlDbType.VarChar, 4000);
			sqlSetResult.Parameters.Add("@applydate", SqlDbType.DateTime, 8);
			sqlSetResult.CommandTimeout = 120;
			
			System.Threading.Thread.Sleep(1000);

			timer.Interval = 1000;
			timer.Enabled = (ConfigurationSettings.AppSettings["ProcessTicket"].Equals("true") ? true : false);
		}
Exemplo n.º 30
0
 /// <summary>
 ///     Start checking for new version of application and display dialog to the user if update is available.
 /// </summary>
 /// <param name="done">Call when it is done.</param>
 public static void Start(DoneDelegate done = null)
 {
     Current.StartChecking(done: done);
 }
Exemplo n.º 31
0
 //===========================[ Set Translated Languag ]=========================//
 public bool SetTranslatedLanguage(DoneDelegate callback, TranslateLanguage targetLanguage, int timeout = 0)
 {
     return(SetTranslatedLanguage(callback, GetTranslatedLanguage(targetLanguage), timeout));
 }
Exemplo n.º 32
0
        //===========================[ Delete Chat ]=========================//
        //-- xid: peer uid, or groupId, or roomId
        //-- type: 1: p2p, 2: group; 3: room

        public bool DeleteChat(DoneDelegate callback, long xid, long mid, int type, int timeout = 0)
        {
            return(DeleteMessage(callback, xid, mid, type, timeout));
        }
Exemplo n.º 33
0
 /// <summary>
 /// Find co-occurring words with query word.
 /// </summary>
 public void Query(string word, int minFreq, int maxFreq, DoneDelegate done, int wleft, int wright)
 {
     ThreadPool.QueueUserWorkItem(doQuery, new object[] { word, done, minFreq, maxFreq, wleft, wright });
 }
Exemplo n.º 34
0
        private void doQuery(object state)
        {
            object[]     args    = (object[])state;
            DoneDelegate done    = (DoneDelegate)args[1];
            string       word    = (string)args[0];
            int          minFreq = (int)args[2];

            if (minFreq <= 0)
            {
                minFreq = int.MaxValue;
            }
            int maxFreq = (int)args[3];

            if (maxFreq <= 0)
            {
                maxFreq = int.MaxValue;
            }
            int wleft = (int)args[4];

            if (wleft <= 0)
            {
                wleft = int.MaxValue;
            }
            int wright = (int)args[5];

            if (wright <= 0)
            {
                wright = int.MaxValue;
            }

            coCounts.Clear();
            qCount     = 0;
            eventCount = 0;
            ResArr.Clear();
            using (StreamReader sr = new StreamReader("segm.txt"))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    ++eventCount;
                    string[] parts = line.Split(' ');
                    int      wPos  = -1;
                    for (int i = 0; i != parts.Length; ++i)
                    {
                        if (parts[i] == word)
                        {
                            wPos = i; break;
                        }
                    }
                    if (wPos == -1)
                    {
                        continue;
                    }
                    ++qCount;

                    for (int i = wPos + 1; i < parts.Length && i - wPos <= wright; ++i)
                    {
                        string str = parts[i];
                        if (str == word)
                        {
                            continue;
                        }
                        if (!freqs.ContainsKey(str))
                        {
                            continue;
                        }
                        int freq = freqs[str];
                        if (freq < minFreq || freq > maxFreq)
                        {
                            continue;
                        }
                        if (!coCounts.ContainsKey(str))
                        {
                            coCounts[str] = 1;
                        }
                        else
                        {
                            ++coCounts[str];
                        }
                    }

                    for (int i = wPos - 1; i >= 0 && wPos - i >= wleft; --i)
                    {
                        string str = parts[i];
                        if (str == word)
                        {
                            continue;
                        }
                        if (!freqs.ContainsKey(str))
                        {
                            continue;
                        }
                        int freq = freqs[str];
                        if (freq < minFreq || freq > maxFreq)
                        {
                            continue;
                        }
                        if (!coCounts.ContainsKey(str))
                        {
                            coCounts[str] = 1;
                        }
                        else
                        {
                            ++coCounts[str];
                        }
                    }
                }
            }

            foreach (var x in coCounts)
            {
                Result res = new Result(x.Key, getLL(x.Key, x.Value), getChSqCorr(x.Key, x.Value));
                ResArr.Add(res);
            }
            //Array.Sort(resArr, (x, y) => y.LL.CompareTo(x.LL));
            //Array.Sort(resArr, (x, y) => y.ChSqCorr.CompareTo(x.ChSqCorr));

            done();
        }