public static void cancelInquiry(InquiriesDataContext dbContext, long inquiryId) { inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId); myInquiry.status = 4; myInquiry.inquiry_end = DateTime.Now; dbContext.SubmitChanges(); }
//Starts proposal phase, sets status and sends out invitations public static void startProposalPhase(long inquiryId, string[] jeids, string message, DateTime propstart, DateTime propend) { InquiriesDataContext dbContext = new InquiriesDataContext(); inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId); myInquiry.proposal_start = propstart; myInquiry.proposal_end = propend; myInquiry.status = 2; dbContext.SubmitChanges(); List<string> receivers = new List<string>(); foreach (var single in jeids) { likes like = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == single); like.status = 2; receivers.Add(like.email); } dbContext.SubmitChanges(); //Send Web Service request send.proposalrequest //Load user name from uid Guid userKey = new Guid(myInquiry.uid); MembershipUser user = Membership.GetUser(userKey); //Load profile from username ProfileCommon pObj = new ProfileCommon().GetProfile(user.UserName); Dictionary<string, dynamic> args = new Dictionary<string, dynamic>(); args.Add("method", "send.proposalrequest"); args.Add("companyname", pObj.CompanyName); args.Add("iid", myInquiry.iid); args.Add("receivers", jeids); args.Add("title", "Proposal submit invitation"); args.Add("message", message); WebRequestHandler.load(args); //Send introductory message to junior enterprises MessageManager.send(receivers.ToArray(), "Invitation to submit proposal for " + myInquiry.title, message); }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid && Profile.Status > 1) { //If File has been uploaded string newfilepath = ""; bool fileOK = false; string path = Server.MapPath("~/Files/"); if (FileUpload1.HasFile) { string filePath = FileUpload1.FileName; if (filePath.EndsWith(".doc") || filePath.EndsWith(".docx") || filePath.EndsWith(".pdf")) { double fileSize = FileUpload1.FileBytes.Length; double fileSizeInMB = fileSize / (1024 * 1024); if (fileSizeInMB < 20) { fileOK = true; } } } if (fileOK) { try { newfilepath = path + FileUpload1.FileName; FileUpload1.PostedFile.SaveAs(newfilepath); FileUploadedLabel.Text = FileUpload1.FileName; } catch (Exception ex) { } } using (InquiriesDataContext inquiryDb = new InquiriesDataContext()) { //If existing inquiry ist updated if (Request.QueryString["iid"] != "" && Request.QueryString["iid"] != null) { int inquiryid; Int32.TryParse(Request.QueryString["iid"], out inquiryid); inquiries newInquiry = inquiryDb.inquiries.Single(p => p.iid == inquiryid); //Check if user has access MembershipUser myUser = Membership.GetUser(); if (newInquiry.uid == myUser.ProviderUserKey.ToString()) { newInquiry.title = TitleTextBox.Text; newInquiry.description = DescriptionTextBox.Text; newInquiry.interest_start = DateTime.ParseExact(InterestPhaseTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); newInquiry.interest_end = DateTime.ParseExact(InterestPhaseEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); newInquiry.updated = DateTime.Now; //New file uploaded if (newfilepath != "") { files newfile = new files(); newfile.filename = FileUpload1.FileName; newfile.filepath = newfilepath; newfile.filesize = FileUpload1.FileBytes.Length; newfile.created = DateTime.Now; newfile.inquiries.Add(newInquiry); } } //If already in proposal phase let users change proposal dates if (newInquiry.status == 2) { newInquiry.proposal_start = DateTime.ParseExact(ProposalStartTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); newInquiry.proposal_end = DateTime.ParseExact(ProposalEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); } inquiryDb.SubmitChanges(); //Send update webservice request Dictionary<string, dynamic> args = new Dictionary<string, dynamic>(); args.Add("method", "update.inquiry"); args.Add("iid", newInquiry.iid); args.Add("uid", newInquiry.uid); args.Add("companyname", Profile.CompanyName); args.Add("title", newInquiry.title); args.Add("description", newInquiry.description); if(newInquiry.files != null) { args.Add("filepath", newInquiry.files.filepath); } //Convert datetime to unix timestamp DateTime unixStart = new DateTime(1970, 1, 1); if (newInquiry.interest_start != null) { TimeSpan span = new TimeSpan(newInquiry.interest_start.Value.Ticks - unixStart.Ticks); args.Add("interest_start", Convert.ToInt32(span.TotalSeconds)); } else { args.Add("interest_start", ""); } if (newInquiry.interest_end != null) { TimeSpan span2 = new TimeSpan(newInquiry.interest_end.Value.Ticks - unixStart.Ticks); args.Add("interest_end", Convert.ToInt32(span2.TotalSeconds)); } else { args.Add("interest_end", ""); } if (newInquiry.proposal_start != null) { TimeSpan span3 = new TimeSpan(newInquiry.proposal_start.Value.Ticks - unixStart.Ticks); args.Add("proposal_start", Convert.ToInt32(span3.TotalSeconds)); } else { args.Add("proposal_start", ""); } if (newInquiry.proposal_end != null) { TimeSpan span4 = new TimeSpan(newInquiry.proposal_end.Value.Ticks - unixStart.Ticks); args.Add("proposal_end", Convert.ToInt32(span4.TotalSeconds)); } else { args.Add("proposal_end", ""); } if (newInquiry.inquiry_end != null) { TimeSpan span5 = new TimeSpan(newInquiry.inquiry_end.Value.Ticks - unixStart.Ticks); args.Add("inqiry_end", Convert.ToInt32(span5.TotalSeconds)); } else { args.Add("inquiry_end", ""); } WebRequestHandler.load(args); StatusLabel.Visible = true; StatusLabel.Text = "Inquiry updated"; } //If new inquiry is created else { inquiries myInquiry = new inquiries(); myInquiry.title = TitleTextBox.Text; myInquiry.description = DescriptionTextBox.Text; DateTime intereststart; myInquiry.interest_start = intereststart = DateTime.ParseExact(InterestPhaseTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); DateTime interestend; myInquiry.interest_end = interestend = DateTime.ParseExact(InterestPhaseEndTextBox.Text, "yyyy-MM-dd", CultureInfo.InvariantCulture); myInquiry.created = myInquiry.updated = DateTime.Today; MembershipUser myUser = Membership.GetUser(); myInquiry.uid = myUser.ProviderUserKey.ToString(); myInquiry.status = 1; //New file uploaded if (newfilepath != "") { files newfile = new files(); newfile.filename = FileUpload1.FileName; newfile.filepath = newfilepath; newfile.filesize = FileUpload1.FileBytes.Length; newfile.created = DateTime.Now; newfile.inquiries.Add(myInquiry); } inquiryDb.inquiries.InsertOnSubmit(myInquiry); inquiryDb.SubmitChanges(); Dictionary<string, dynamic> args = new Dictionary<string, dynamic>(); args.Add("method", "send.inquiry"); args.Add("iid", myInquiry.iid); args.Add("uid", myInquiry.uid); args.Add("companyname", Profile.CompanyName); args.Add("title", myInquiry.title); args.Add("description", myInquiry.description); args.Add("status", myInquiry.status); if (newfilepath != "") { args.Add("filepath", newfilepath); } //Convert datetime to unix timestamp DateTime unixStart = new DateTime(1970, 1, 1); TimeSpan span = new TimeSpan(intereststart.Ticks - unixStart.Ticks); args.Add("interest_start", Convert.ToInt32(span.TotalSeconds)); TimeSpan span2 = new TimeSpan(interestend.Ticks - unixStart.Ticks); args.Add("interest_end", Convert.ToInt32(span2.TotalSeconds)); WebRequestHandler.load(args); Response.Redirect("InquiryOverview.aspx"); } //Server.Transfer("InquiryOverview.aspx", false); } } }
public static bool addLike(long inquiryId, string jeid, string name, string email) { InquiriesDataContext dbContext = new InquiriesDataContext(); //Check if like already present likes myLike = null; try { myLike = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == jeid); } catch (Exception ex) { //Sequence is empty } if (myLike == null) { likes newLike = new likes(); newLike.created = DateTime.Now; newLike.iid = inquiryId; newLike.jeid = jeid; newLike.name = name; newLike.email = email; //Status 1 == normal active, Status 2 == invited to proposal, Status 3 == proposal submitted, Status 4 == propsal accepted newLike.status = 1; dbContext.likes.InsertOnSubmit(newLike); dbContext.SubmitChanges(); return true; } else { return false; } }
public static void endInquiry(InquiriesDataContext dbContext, long inquiryId, string jeId, string endMessage) { inquiries myInquiry = dbContext.inquiries.Single(p => p.iid == inquiryId); if (myInquiry != null) { var query = from likes in dbContext.likes where likes.iid == inquiryId where likes.status == 3 select likes; List<string> audience = new List<string>(); if (query.Count() != 0) { foreach (var like in query) { if (like.jeid != jeId) { audience.Add(like.email); } else { like.status = 4; } } } string message = "Your proposal was not accepted - Please try again at the next inquiry"; if (endMessage != "") { message = endMessage; } myInquiry.inquiry_end = DateTime.Now; myInquiry.status = 3; dbContext.SubmitChanges(); MessageManager.send(audience.ToArray(), "Your proposal for " + myInquiry.title + " was not accepted", message); } }
public static bool invalidateJeprofile(string jeid) { InquiriesDataContext dbcontext = new InquiriesDataContext(); var query = from likes in dbcontext.likes where likes.jeid == jeid where likes.inquiries.status > 2 select likes; if (query.Count() != 0) { //Get new Je Profile data Dictionary<string, dynamic> args = new Dictionary<string,dynamic>(); args.Add("method", "load.jeprofile"); args.Add("jeid", jeid); String result = WebRequestHandler.load(args); //Get the results JObject resultObject = JObject.Parse(result); JToken results; if (resultObject.TryGetValue("results", out results)) { IList<JToken> resultList = results.Children().ToList(); JuniorEnterprise je = null; foreach (JToken item in resultList) { je = JsonConvert.DeserializeObject<JuniorEnterprise>(item.ToString()); } //If we got something from the Web Request if (je != null) { foreach (var item in query) { item.email = je.email; item.name = je.name; } dbcontext.SubmitChanges(); return true; } } } return false; }
public static bool addProposal(long inquiryId, string jeid, string url) { InquiriesDataContext dbContext = new InquiriesDataContext(); //Update existing like status likes myLike = null; try { myLike = dbContext.likes.Single(p => p.iid == inquiryId && p.jeid == jeid); } catch (Exception ex) { //No inquiry there } if (myLike != null) { myLike.status = 3; files newFile = new files(); newFile.created = DateTime.Now; newFile.external_url = url; newFile.likes.Add(myLike); dbContext.SubmitChanges(); return true; } else { return false; } }