コード例 #1
0
 public void AddGroupScheduleMessage(Domain.Myfashion.Domain.GroupScheduleMessage _GroupScheduleMessage)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to save data.
             session.Save(_GroupScheduleMessage);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
コード例 #2
0
        public Domain.Myfashion.Domain.GroupScheduleMessage GetScheduleMessageId(Guid ScheduleMessageId)
        {
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        NHibernate.IQuery query = session.CreateQuery("from GroupScheduleMessage  where ScheduleMessageId = : schedulemessageid");
                        query.SetParameter("schedulemessageid", ScheduleMessageId);

                        Domain.Myfashion.Domain.GroupScheduleMessage result = (Domain.Myfashion.Domain.GroupScheduleMessage)query.UniqueResult();
                        return(result);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                }
            }
        }
コード例 #3
0
        public static string PostOnSelectedGroups(string SelectedGroupId, string title, string msg, string intrval, string clienttime, string time, string date, string imagefile)
        {

            User objUser = (User)System.Web.HttpContext.Current.Session["User"];
            try
            {
                ScheduledMessage _ScheduledMessage = new ScheduledMessage();
                GroupScheduleMessage _GroupScheduleMessage = new GroupScheduleMessage();


                Api.ScheduledMessage.ScheduledMessage ApiobjScheduledMessage = new Api.ScheduledMessage.ScheduledMessage();
                ApiobjScheduledMessage.Timeout = 300000;
                Api.GroupScheduleMessage.GroupScheduleMessage ApiObjGrpSchduleMessage = new Api.GroupScheduleMessage.GroupScheduleMessage();
                ApiObjGrpSchduleMessage.Timeout = 300000;

                int intervaltime = Convert.ToInt32(intrval);

                HttpContext.Current.Session["scheduletime"] = null;
                var SelctGroupId = SelectedGroupId.ToString().Split(',');


                foreach (var item in SelctGroupId)
                {
                    string[] networkingwithid = item.Split(new string[] { "*#*" }, StringSplitOptions.None);


                    if (networkingwithid[1] == "fb")
                    {
                        try
                        {
                            string facebookgrouppost = string.Empty;
                            string groupid = networkingwithid[2];
                            string profileid = networkingwithid[0];
                            
                            _ScheduledMessage.CreateTime = DateTime.Now;
                            _ScheduledMessage.ProfileType = "facebookgroup";
                            _ScheduledMessage.ProfileId = profileid;
                            _ScheduledMessage.Id = Guid.NewGuid();
                            if (!string.IsNullOrEmpty(imagefile))
                            {
                               
                                _ScheduledMessage.PicUrl = imagefile;
                            }
                            else
                            {
                                _ScheduledMessage.PicUrl = "";
                            }

                            _ScheduledMessage.ShareMessage = msg;
                            _ScheduledMessage.UserId = objUser.Id;
                            _ScheduledMessage.Status = false;
                            Domain.Myfashion.Domain.ScheduledMessage _Schedulemessage = (Domain.Myfashion.Domain.ScheduledMessage)new JavaScriptSerializer().Deserialize(ApiobjScheduledMessage.AddGroupScheduleMessages(date + " " + time, "it will create at server", _ScheduledMessage.ProfileType.ToString(), _ScheduledMessage.ProfileId.ToString(), _ScheduledMessage.PicUrl.ToString(), clienttime, _ScheduledMessage.ShareMessage.ToString(), _ScheduledMessage.UserId.ToString(), _ScheduledMessage.Status.ToString()), typeof(Domain.Myfashion.Domain.ScheduledMessage));

                            _GroupScheduleMessage.Id = Guid.NewGuid();
                            _GroupScheduleMessage.ScheduleMessageId = _Schedulemessage.Id;
                            _GroupScheduleMessage.GroupId = groupid;
                            ApiObjGrpSchduleMessage.AddGroupScheduleMessage(_GroupScheduleMessage.ScheduleMessageId.ToString(), _GroupScheduleMessage.GroupId.ToString());
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (networkingwithid[1] == "lin")
                    {
                        try
                        {
                            string groupid = networkingwithid[2];
                            string profileid = networkingwithid[0];
                           
                            string message = title + "$%^_^%$" + msg;
                            _ScheduledMessage.CreateTime = DateTime.Now;
                            _ScheduledMessage.ProfileType = "linkedingroup";
                            _ScheduledMessage.ProfileId = profileid;
                            _ScheduledMessage.Id = Guid.NewGuid();
                            if (!string.IsNullOrEmpty(imagefile))
                            {
                                
                                _ScheduledMessage.PicUrl = imagefile;

                            }
                            else
                            {
                                _ScheduledMessage.PicUrl = "";
                            }
                            _ScheduledMessage.ClientTime = Convert.ToDateTime(clienttime);
                            _ScheduledMessage.ShareMessage = message; ;
                            _ScheduledMessage.UserId = objUser.Id;
                            _ScheduledMessage.Status = false;
                            Domain.Myfashion.Domain.ScheduledMessage _Schedulemessage = (Domain.Myfashion.Domain.ScheduledMessage)new JavaScriptSerializer().Deserialize(ApiobjScheduledMessage.AddGroupScheduleMessages(date + " " + time, "it will create at server", _ScheduledMessage.ProfileType.ToString(), _ScheduledMessage.ProfileId.ToString(), _ScheduledMessage.PicUrl.ToString(), clienttime, _ScheduledMessage.ShareMessage.ToString(), _ScheduledMessage.UserId.ToString(), _ScheduledMessage.Status.ToString()), typeof(Domain.Myfashion.Domain.ScheduledMessage));

                            _GroupScheduleMessage.Id = Guid.NewGuid();
                            _GroupScheduleMessage.ScheduleMessageId = _Schedulemessage.Id;
                            _GroupScheduleMessage.GroupId = groupid;
                            ApiObjGrpSchduleMessage.AddGroupScheduleMessage(_GroupScheduleMessage.ScheduleMessageId.ToString(), _GroupScheduleMessage.GroupId.ToString());
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return "success";
        }
コード例 #4
0
        public string ScheduleLinkedinGroupMessage(string scheduledmsgguid, string Userid, string profileid)
        {
            string str = string.Empty;

            try
            {
                LinkedInAccount           linkacc;
                string                    authLink        = string.Empty;
                LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository();
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(scheduledmsgguid));
                GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository();
                Domain.Myfashion.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id);
                if (linkedinAccRepo.checkLinkedinUserExists(profileid, Guid.Parse(Userid)))
                {
                    linkacc = linkedinAccRepo.getUserInformation(Guid.Parse(Userid), profileid);
                }
                else
                {
                    linkacc = linkedinAccRepo.getUserInformation(profileid);
                }
                oAuthLinkedIn oauthlin = new oAuthLinkedIn();
                oauthlin.ConsumerKey    = ConfigurationManager.AppSettings["LiApiKey"];
                oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"];
                oauthlin.FirstName      = linkacc.LinkedinUserName;
                oauthlin.Id             = linkacc.LinkedinUserId;
                oauthlin.Token          = linkacc.OAuthToken;
                oauthlin.TokenSecret    = linkacc.OAuthSecret;
                oauthlin.Verifier       = linkacc.OAuthVerifier;

                string   imgurl  = objScheduledMessage.PicUrl;
                string   text    = objScheduledMessage.ShareMessage;
                string[] arrtext = null;
                try
                {
                    arrtext = System.Text.RegularExpressions.Regex.Split(text, "$%^_^%$");
                    if (arrtext.Count() == 1)
                    {
                        arrtext = null;
                        arrtext = text.Split(new string[] { "$%^_^%$" }, StringSplitOptions.None);
                    }
                }
                catch (Exception ex)
                {
                    return("somthing went wrong");
                }
                string Title    = arrtext[0];
                string Message  = arrtext[1];
                string response = string.Empty;
                if (linkacc != null)
                {
                    try
                    {
                        if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage) && string.IsNullOrEmpty(objScheduledMessage.PicUrl))
                        {
                            str = "There is no data in Share Message !";
                        }
                        else
                        {
                            SocialStream sociostream = new SocialStream();
                            if (!string.IsNullOrEmpty(imgurl))
                            {
                                imgurl   = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(imgurl, "wwwroot")[1].Replace("\\", "/");
                                response = sociostream.SetImagePostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title, imgurl);
                            }
                            else
                            {
                                response = sociostream.SetPostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    str = "Message post on linkedingroup for Id :" + linkacc.LinkedinUserId + ", Title: " + Title + " and Message: " + Message;
                    ScheduledMessage schmsg = new ScheduledMessage();
                    schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(scheduledmsgguid));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                str = ex.Message;
            }
            return(str);
        }